Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create the main serverless function with the cdk #3

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore(app): add typing for environment variables
  • Loading branch information
tericcabrel committed Mar 21, 2022
commit 491fb4083b636bc8e2db5cb513eb05e6b495c4dd
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist
.next
.turbo
coverage
env.d.ts
12 changes: 12 additions & 0 deletions apps/core/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type EnvironmentVariables = {
HOST: string;
PORT: string;
};

declare global {
namespace NodeJS {
interface ProcessEnv extends EnvironmentVariables {}
}
}

export {};
8 changes: 4 additions & 4 deletions apps/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { sortNumbers } from '@sharingan/utils';

dotenv.config();

const HOST = process.env.HOST ?? 'https://localhost';
const PORT = parseInt(process.env.PORT ?? '7501');
const { HOST, PORT } = process.env;
const SERVER_PORT = parseInt(PORT ?? '7501');

const app = express();

Expand All @@ -16,8 +16,8 @@ app.get('/', (_req, res) => {
return res.json({ message: 'Hello World!' });
});

app.listen(PORT, () => {
app.listen(SERVER_PORT, () => {
console.log(sortNumbers([67, 80, 4, 11, 90, 54, 22]));

console.log(`Application started on URL ${HOST}:${PORT} 🎉`);
console.log(`Application started on URL ${HOST}:${SERVER_PORT} 🎉`);
});
1 change: 1 addition & 0 deletions apps/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"composite": true,
"sourceMap": true
},
"files": ["env.d.ts"],
"include": [
"./src/**/*", "./tests/**/*"
],
Expand Down
2 changes: 1 addition & 1 deletion apps/web/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
}
}
],
"ignorePatterns": ["jest.config.js", "__mocks__"]
"ignorePatterns": ["jest.config.js", "__mocks__", "next.config.js"]
}
11 changes: 11 additions & 0 deletions apps/web/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type EnvironmentVariables = {
APP_ENV: string;
};

declare global {
namespace NodeJS {
type ProcessEnv = EnvironmentVariables;
}
}

export {};