-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add cross-env for seamless Windows support * Initial object endpoints * Add mongodb memory server for easier testing * Rename Object to Offer * Add flat package * bug fixes, flatten body before updating, better error formatting * surname -> lastName to pass tests * update roleCheck for easier usage * Add authorization * Add @types/jest package for jest suggestions in vscode * Improve error messages * Add tests * fix casing to pass github actions tests * fix auth * reenable tests * cleanup * apply suggestions
- Loading branch information
Showing
17 changed files
with
527 additions
and
66 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,5 +1,4 @@ | ||
MONGO_URL = | ||
MONGO_TEST_URL = | ||
PORT = | ||
JWT_SECRET = | ||
JWT_EXP = |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 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 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,6 +1,6 @@ | ||
import request from 'supertest'; | ||
import { app } from '../app.js'; | ||
import { connect, disconnect } from '../helpers/testDbConnection.js'; | ||
import dbConnection from '../helpers/dbConnection.js'; | ||
|
||
const userBody = { | ||
email: `[email protected]`, | ||
|
@@ -22,10 +22,10 @@ let token; | |
|
||
describe('auth endpoints', () => { | ||
beforeAll(async () => { | ||
await connect(); | ||
await dbConnection.connect(); | ||
}); | ||
afterAll(async () => { | ||
await disconnect(); | ||
await dbConnection.disconnect(); | ||
}); | ||
|
||
it('should allow a POST to /auth/register with correct data', async () => { | ||
|
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 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,21 +1,9 @@ | ||
import mongoose from 'mongoose'; | ||
import * as productionDbConnection from './productionDbConnection.js'; | ||
import * as testDbConnection from './testDbConnection.js'; | ||
|
||
const dbUri = | ||
process.env.NODE_ENV === 'test' | ||
? process.env.MONGO_TEST_URL | ||
: process.env.MONGO_URL; | ||
const dbConnection = | ||
process.env.NODE_ENV === 'production' | ||
? productionDbConnection | ||
: testDbConnection; | ||
|
||
export const dbConnection = async () => { | ||
try { | ||
await mongoose.connect(dbUri, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
}); | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
}; | ||
|
||
export const closeConnection = () => { | ||
return mongoose.disconnect(); | ||
}; | ||
export default dbConnection; |
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 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
export const connect = async () => { | ||
try { | ||
await mongoose.connect(process.env.MONGO_URL, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
}); | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
}; | ||
|
||
export const disconnect = () => { | ||
return mongoose.disconnect(); | ||
}; |
Oops, something went wrong.