wip(backend): Added prettier
This commit is contained in:
parent
34a65befa7
commit
1f312c6548
5 changed files with 36 additions and 23 deletions
|
@ -7,7 +7,8 @@
|
|||
"test": "npx mocha tests/*.test.mjs",
|
||||
"initdb": "npx prisma db push",
|
||||
"newdb": "node ./scripts/newdb.mjs",
|
||||
"rmdb": "node ./scripts/rmdb.mjs"
|
||||
"rmdb": "node ./scripts/rmdb.mjs",
|
||||
"prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "4.5.0",
|
||||
|
|
|
@ -30,8 +30,7 @@ const config = {
|
|||
expiresIn: process.env.API_JWT_EXPIRY || '36 days',
|
||||
},
|
||||
languages: ['en', 'de', 'es', 'fr', 'nl'],
|
||||
ses: {
|
||||
},
|
||||
ses: {},
|
||||
oauth: {
|
||||
github: {
|
||||
clientId: process.env.API_GITHUB_CLIENT_ID,
|
||||
|
@ -165,16 +164,27 @@ export function verifyConfig() {
|
|||
}
|
||||
|
||||
if (process.env.API_DUMP_CONFIG_AT_STARTUP) {
|
||||
console.log("Dumping configuration:", JSON.stringify({
|
||||
console.log(
|
||||
'Dumping configuration:',
|
||||
JSON.stringify(
|
||||
{
|
||||
...config,
|
||||
encryption: {
|
||||
...config.encryption,
|
||||
key: config.encryption.key.slice(0, 4) + '[ REDACTED ]' + config.encryption.key.slice(-4),
|
||||
key:
|
||||
config.encryption.key.slice(0, 4) + '[ REDACTED ]' + config.encryption.key.slice(-4),
|
||||
},
|
||||
jwt: {
|
||||
secretOrKey: config.jwt.secretOrKey.slice(0, 4) + '[ REDACTED ]' + config.jwt.secretOrKey.slice(-4),
|
||||
}
|
||||
}, null, 2))
|
||||
secretOrKey:
|
||||
config.jwt.secretOrKey.slice(0, 4) +
|
||||
'[ REDACTED ]' +
|
||||
config.jwt.secretOrKey.slice(-4),
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return config
|
||||
|
|
|
@ -29,7 +29,7 @@ const params = {
|
|||
app,
|
||||
passport,
|
||||
...encryption(config.encryption.key),
|
||||
config
|
||||
config,
|
||||
}
|
||||
// Load routes
|
||||
for (const type in routes) routes[type](params)
|
||||
|
|
|
@ -22,7 +22,4 @@ function loadPassportMiddleware(passport, config) {
|
|||
)
|
||||
}
|
||||
|
||||
export {
|
||||
loadExpressMiddleware,
|
||||
loadPassportMiddleware,
|
||||
}
|
||||
export { loadExpressMiddleware, loadPassportMiddleware }
|
||||
|
|
|
@ -7,7 +7,6 @@ const expect = chai.expect
|
|||
chai.use(http)
|
||||
|
||||
describe('Non language-specific User controller signup routes', () => {
|
||||
|
||||
it('Should return 400 on signup without body', (done) => {
|
||||
chai
|
||||
.request(config.api)
|
||||
|
@ -23,14 +22,20 @@ describe('Non language-specific User controller signup routes', () => {
|
|||
let data = {
|
||||
email: 'test@freesewing.org',
|
||||
language: 'en',
|
||||
password: 'one two one two, this is just a test'
|
||||
password: 'one two one two, this is just a test',
|
||||
}
|
||||
Object.keys(data).map(key => {
|
||||
Object.keys(data).map((key) => {
|
||||
it(`Should not create signup without ${key}`, (done) => {
|
||||
chai
|
||||
.request(config.api)
|
||||
.post('/signup')
|
||||
.send(Object.fromEntries(Object.keys(data).filter(name => name !== key).map(name => [name, data[name]])))
|
||||
.send(
|
||||
Object.fromEntries(
|
||||
Object.keys(data)
|
||||
.filter((name) => name !== key)
|
||||
.map((name) => [name, data[name]])
|
||||
)
|
||||
)
|
||||
.end((err, res) => {
|
||||
expect(err === null).to.equal(true)
|
||||
expect(res.status).to.equal(400)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue