Skip to content

Commit

Permalink
Updated for prod and dev testing db.
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-sth committed Dec 10, 2023
1 parent 1c4ce31 commit 337c4c5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
.env
28 changes: 24 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"body-parser": "^1.20.2",
"config": "^3.3.9",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"joi": "^17.11.0",
Expand All @@ -24,7 +25,7 @@
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.11",
"@types/node": "^20.6.5",
"@types/node": "^20.10.4",
"@types/supertest": "^2.0.16",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
Expand Down
2 changes: 2 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import isOnline from './routes/isOnline';
import project from './routes/project';
import connectToDatabase from './startup/db';
import addRateLimiter from './startup/limitRate';
import * as dotenv from 'dotenv';
dotenv.config();

const app: Express = express();

Expand Down
2 changes: 1 addition & 1 deletion src/startup/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mongoose from 'mongoose';

const connectToDatabase = async () => {
try {
await mongoose.connect('mongodb://127.0.0.1:27017/berlin');
await mongoose.connect(process.env.db);
} catch (error) {
console.error('Error connecting to MongoDB:', error.message);
throw error;
Expand Down
4 changes: 2 additions & 2 deletions test/routes/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ describe('Project Routes Tests', () => {
});

it('should get projects when GET /:id', async () => {
const response = await app.get('/project/6574e248ed4efbe66d836229');
const response = await app.get('/project/65750b72771d33966c6da5cc');
expect(response.status).toBe(200);
expect(response.body.name).toEqual('GetSpecialId');
expect(response.body._id).toEqual('6574e248ed4efbe66d836229');
expect(response.body._id).toEqual('65750b72771d33966c6da5cc');
});

it('should create a project when POST /', async () => {
Expand Down

0 comments on commit 337c4c5

Please sign in to comment.