Skip to content

Commit

Permalink
MIT licence, added config for deployment to Zeit Now
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed Jun 16, 2018
1 parent 7c19ff5 commit 7231f6a
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 551 deletions.
21 changes: 11 additions & 10 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "api-async",
"name": "saas-api",
"version": "0.0.1",
"license": "UNLICENSED",
"license": "MIT",
"scripts": {
"dev": "nodemon server/app.ts",
"build": "tsc --project tsconfig.json",
"start": "node production-server/index.js",
"now": "now && now alias && now rm api-async --safe --yes",
"start": "NODE_ENV=production node production-server/app.js",
"now": "now && now alias && now rm saas-api --safe --yes",
"lint": "tslint components pages lib server",
"test": "jest --coverage",
"processes-8000": "ss -lptn 'sport = :8000'",
Expand All @@ -17,6 +17,8 @@
},
"dependencies": {
"@octokit/rest": "^15.8.2",
"@types/mongoose": "^5.0.16",
"@types/node": "^10.3.3",
"aws-sdk": "^2.255.1",
"compression": "^1.7.2",
"connect-mongo": "^2.0.0",
Expand All @@ -39,15 +41,15 @@
"qs": "^6.5.2",
"request": "^2.87.0",
"stripe": "^6.1.1",
"typescript": "2.8.3",
"winston": "^3.0.0-rc5"
},
"devDependencies": {
"@types/express": "^4.11.1",
"@types/handlebars": "^4.0.37",
"@types/express": "^4.16.0",
"@types/handlebars": "^4.0.38",
"@types/lodash": "^4.14.109",
"@types/mongoose": "^5.0.14",
"@types/passport": "^0.4.5",
"@types/stripe": "^5.0.10",
"@types/stripe": "^5.0.13",
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
Expand All @@ -57,7 +59,6 @@
"jest": "^22.4.4",
"nodemon": "^1.17.4",
"ts-node": "^6.0.3",
"tslint": "^5.10.0",
"typescript": "2.8.3"
"tslint": "^5.10.0"
}
}
6 changes: 3 additions & 3 deletions api/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require('dotenv').config();

const dev = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 8000;
const ROOT_URL = dev ? `http://localhost:${port}` : 'https://api1.async-await.com';
const ROOT_URL = dev ? `http://localhost:${port}` : 'https://saas-api.async-await.com';

let MONGO_URL = dev ? process.env.MONGO_URL_TEST : process.env.MONGO_URL;

Expand All @@ -27,7 +27,7 @@ mongoose.connect(MONGO_URL);
const server = express();

const appPort = process.env.APP_PORT || 3000;
const origin = dev ? `http://localhost:${appPort}` : 'https://app1.async-await.com';
const origin = dev ? `http://localhost:${appPort}` : 'https://saas-app.async-await.com';
server.use(cors({ origin, credentials: true }));

server.use(helmet());
Expand Down Expand Up @@ -64,7 +64,7 @@ api(server);

server.get('/uploaded-file', async (req, res) => {
if (!req.user) {
res.redirect(dev ? 'http://localhost:3000/login' : 'https://app1.async-await.com/login');
res.redirect(dev ? 'http://localhost:3000/login' : 'https://saas-app.async-await.com/login');
return;
}

Expand Down
6 changes: 3 additions & 3 deletions api/server/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function auth({ ROOT_URL, server }) {
}

if (req.user && req.user.isAdmin) {
res.redirect(dev ? 'http://localhost:3000/admin' : 'https://app1.async-await.com/admin');
res.redirect(dev ? 'http://localhost:3000/admin' : 'https://saas-app.async-await.com/admin');
} else {
let redirectUrlAfterLogin;

Expand All @@ -103,14 +103,14 @@ export default function auth({ ROOT_URL, server }) {
res.redirect(
dev
? `http://localhost:3000/${redirectUrlAfterLogin}`
: `https://app1.async-await.com/${redirectUrlAfterLogin}`,
: `https://saas-app.async-await.com/${redirectUrlAfterLogin}`,
);
}
},
);

server.get('/logout', (req, res) => {
req.logout();
res.redirect(dev ? 'http://localhost:3000/login' : 'https://app1.async-await.com/login');
res.redirect(dev ? 'http://localhost:3000/login' : 'https://saas-app.async-await.com/login');
});
}
2 changes: 1 addition & 1 deletion api/server/models/Invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import logger from '../logs';
import sendEmail from '../aws-ses';

const dev = process.env.NODE_ENV !== 'production';
const ROOT_URL = dev ? `http://localhost:3000` : 'https://app1.async-await.com';
const ROOT_URL = dev ? `http://localhost:3000` : 'https://saas-app.async-await.com';

const mongoSchema = new mongoose.Schema({
teamId: {
Expand Down
Loading

0 comments on commit 7231f6a

Please sign in to comment.