-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a53b3d
commit 8318b7d
Showing
11 changed files
with
7,078 additions
and
1,448 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import app from '../server' | ||
import supertest from 'supertest' | ||
|
||
describe('GET /', () => { | ||
it('should send back some data', async () => { | ||
const res = await supertest(app).get('/') | ||
|
||
expect(res.body.message).toBe('Hello World!') | ||
}) | ||
}) |
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,31 @@ | ||
import merge from 'lodash.merge' | ||
|
||
// make sure default NODE_ENV is set | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'development' | ||
|
||
// set the stage | ||
const stage = process.env.STAGE || 'local' | ||
let envConfig | ||
|
||
// dynamically require each config depending on the stage we're in | ||
if (stage === 'production') { | ||
envConfig = require('./prod').default | ||
} else if (stage === 'staging') { | ||
envConfig = require('./staging').default | ||
} else { | ||
envConfig = require('./local').default | ||
} | ||
|
||
// merge the config with the default config | ||
const defaultConfig = { | ||
stage, | ||
env: process.env.NODE_ENV, | ||
port: 3000, | ||
secrets: { | ||
jwt: process.env.JWT_SECRET, | ||
dbUrl: process.env.DATABASE_URL, | ||
}, | ||
logging: false, | ||
} | ||
|
||
export default merge(defaultConfig, envConfig) |
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,3 @@ | ||
export default { | ||
port: 3000, | ||
} |
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,3 @@ | ||
export default { | ||
port: process.env.PORT, | ||
} |
Empty file.
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,14 @@ | ||
import * as user from '../user' | ||
|
||
describe('user handler', () => { | ||
it('should create a new user', async () => { | ||
const req = { body: { username: 'hello', password: 'hi' } } | ||
const res = { | ||
json({ token }) { | ||
expect(token).toBeTruthy() | ||
}, | ||
} | ||
|
||
await user.signup(req, res, () => {}) | ||
}) | ||
}) |
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,10 +1,8 @@ | ||
import * as dotenv from 'dotenv' | ||
dotenv.config() | ||
|
||
import config from './config' | ||
import app from './server' | ||
|
||
const port = process.env.PORT || 3001 | ||
|
||
app.listen(port, () => { | ||
console.log('Server is running on port', port) | ||
app.listen(config.port, () => { | ||
console.log('Server is running on port', config.port) | ||
}) |
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