Skip to content

Commit e6a4efe

Browse files
authored
Merge pull request #2 from nicolelim02/chore/setup
Set up
2 parents c3ed7dd + cdb904e commit e6a4efe

28 files changed

+11277
-0
lines changed

.github/workflows/lint.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- "*"
10+
11+
env:
12+
NODE_VERSION: 20
13+
14+
jobs:
15+
question-service:
16+
runs-on: ubuntu-latest
17+
name: Question service
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
- name: Setting node version
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ env.NODE_VERSION }}
25+
- name: Install dependences
26+
working-directory: ./backend/question-service
27+
run: npm install
28+
- name: Run eslint
29+
working-directory: ./backend/question-service
30+
run: npm run lint
31+
frontend:
32+
runs-on: ubuntu-latest
33+
name: Frontend
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
- name: Setting node version
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
41+
- name: Install dependencies
42+
working-directory: ./frontend
43+
run: npm install
44+
- name: Run eslint
45+
working-directory: ./frontend
46+
run: npm run lint

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Environment files
27+
.env
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

backend/question-service/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Question Service
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
4+
export default [
5+
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
6+
{ languageOptions: { globals: globals.node } },
7+
pluginJs.configs.recommended,
8+
];

backend/question-service/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import express, { Express, Request, Response } from "express";
2+
import dotenv from "dotenv";
3+
import path from "path";
4+
import swaggerUi from "swagger-ui-express";
5+
import yaml from "yaml";
6+
import fs from "fs";
7+
8+
const envFilePath = path.join(
9+
path.resolve(path.dirname(path.dirname(__dirname))),
10+
".env",
11+
);
12+
13+
const file = fs.readFileSync("./swagger.yml", "utf-8");
14+
const swaggerDocument = yaml.parse(file);
15+
16+
dotenv.config({ path: envFilePath });
17+
18+
const app: Express = express();
19+
20+
const PORT = process.env.QUESTION_SERVICE_PORT || 3000;
21+
22+
app.get("/", (req: Request, res: Response) => {
23+
res.status(200).json({ message: "Hello world from question service" });
24+
});
25+
26+
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
27+
28+
app.listen(PORT, () => console.log(`Listening on port ${PORT}`));

0 commit comments

Comments
 (0)