Skip to content

Commit

Permalink
Merge pull request #4 from CS3219-AY2425S1/init-question
Browse files Browse the repository at this point in the history
Initialize question service
  • Loading branch information
McNaBry authored Sep 18, 2024
2 parents e527baf + 6cf6298 commit 1209688
Show file tree
Hide file tree
Showing 22 changed files with 4,918 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is a sample environment configuration file.
# Copy this file to .env and replace the placeholder values with your own.
QUESTION_DB_CLOUD_URI=<FILL-THIS-IN>
QUESTION_DB_LOCAL_URI=mongodb://question-db:27017/question
QUESTION_DB_USERNAME=user
QUESTION_DB_PASSWORD=password

NODE_ENV=development
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ env:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-frontend:
build-service:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
service: [frontend, services/question]
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install Node Modules
run: cd frontend && npm ci
run: cd ${{ matrix.service }} && npm ci
- name: Linting
run: cd frontend && npm run lint
run: cd ${{ matrix.service }} && npm run lint
- name: Build App
run: cd frontend && npm run build
run: cd ${{ matrix.service }} && npm run build
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,45 @@ services:
volumes:
- /app/node_modules
- ./frontend:/app
networks:
- question-network

question:
container_name: question
image: question
build:
context: services/question
dockerfile: Dockerfile
ports:
- 8081:8081
environment:
DB_CLOUD_URI: ${QUESTION_DB_CLOUD_URI}
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
DB_USERNAME: ${QUESTION_DB_USERNAME}
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
volumes:
- /app/node_modules
- ./services/question:/app
networks:
- question-network
- question-db-network

question-db:
container_name: question-db
image: mongo:7.0.14
environment:
MONGO_INITDB_ROOT_USERNAME: ${QUESTION_DB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${QUESTION_DB_PASSWORD}
volumes:
- question-db:/data/db
networks:
- question-db-network

volumes:
question-db:

networks:
question-network:
driver: bridge
question-db-network:
driver: bridge
9 changes: 9 additions & 0 deletions services/question/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is a sample environment configuration file.
# Copy this file to .env and replace the placeholder values with your own.
DB_CLOUD_URI=<FILL-THIS-IN>
DB_LOCAL_URI=mongodb://question-db:27017/question
DB_USERNAME=user
DB_PASSWORD=password
CORS_ORIGIN=*
PORT=8081
NODE_ENV=development
24 changes: 24 additions & 0 deletions services/question/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
39 changes: 39 additions & 0 deletions services/question/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db

package.json
package-lock.json
11 changes: 11 additions & 0 deletions services/question/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"trailingComma": "all",
"bracketSameLine": true,
"printWidth": 120
}
9 changes: 9 additions & 0 deletions services/question/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20-alpine

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
EXPOSE 8081

CMD ["npm", "start"]
24 changes: 24 additions & 0 deletions services/question/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default tseslint.config({
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintPluginPrettierRecommended,
],
rules: {
// https://stackoverflow.com/questions/68816664/get-rid-of-error-delete-eslint-prettier-prettier-and-allow-use-double
'prettier/prettier': [
'error',
{
'endOfLine': 'auto',
}
]
},
});
Loading

0 comments on commit 1209688

Please sign in to comment.