-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from ntuscse/challenges-backend-bh
feat/ add season codebase to challenges
- Loading branch information
Showing
26 changed files
with
2,560 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
MONGO_URI=mongodb://localhost/ | ||
MONGO_URI=mongodb://localhost:27017/ | ||
MONGO_PORT=27017 | ||
MONGO_DATABSE_NAME=challenges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# this docker-compose file is for convenient setup of a local | ||
# mongodb instance for local testing | ||
version: "3" | ||
services: | ||
challenges-mongo: | ||
image: mongo | ||
container_name: challenges-mongo | ||
restart: always | ||
ports: | ||
- "${MONGO_PORT}:27017" | ||
env_file: | ||
- ./.env | ||
environment: | ||
MONGO_INITDB_DATABASE: ${MONGO_DATABSE_NAME} | ||
volumes: | ||
- ./mock/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
db.createCollection("seasons"); | ||
db.createCollection("rankings"); | ||
db.createCollection("questions"); | ||
db.createCollection("submissions"); | ||
db.createCollection("users"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import moongose from "mongoose"; | ||
import * as dotenv from "dotenv"; | ||
import { ConnectionOptions } from "tls"; | ||
dotenv.config(); | ||
|
||
const connectDB = async () => { | ||
try { | ||
const mongoURL = process.env.MONGO_URI || 'mongodb://localhost:27017'; | ||
const conn = await moongose.connect(mongoURL, { | ||
useNewUrlParser: true, | ||
dbName: process.env.MONGO_DATABSE_NAME || 'challenges', | ||
} as ConnectionOptions); | ||
console.log(`MongoDB Connected: ${mongoURL}`); | ||
} catch (error) { | ||
console.log(error); | ||
process.exit(1) | ||
} | ||
} | ||
|
||
export { connectDB as default }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.