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",
|
"test": "npx mocha tests/*.test.mjs",
|
||||||
"initdb": "npx prisma db push",
|
"initdb": "npx prisma db push",
|
||||||
"newdb": "node ./scripts/newdb.mjs",
|
"newdb": "node ./scripts/newdb.mjs",
|
||||||
"rmdb": "node ./scripts/rmdb.mjs"
|
"rmdb": "node ./scripts/rmdb.mjs",
|
||||||
|
"prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "4.5.0",
|
"@prisma/client": "4.5.0",
|
||||||
|
|
|
@ -30,8 +30,7 @@ const config = {
|
||||||
expiresIn: process.env.API_JWT_EXPIRY || '36 days',
|
expiresIn: process.env.API_JWT_EXPIRY || '36 days',
|
||||||
},
|
},
|
||||||
languages: ['en', 'de', 'es', 'fr', 'nl'],
|
languages: ['en', 'de', 'es', 'fr', 'nl'],
|
||||||
ses: {
|
ses: {},
|
||||||
},
|
|
||||||
oauth: {
|
oauth: {
|
||||||
github: {
|
github: {
|
||||||
clientId: process.env.API_GITHUB_CLIENT_ID,
|
clientId: process.env.API_GITHUB_CLIENT_ID,
|
||||||
|
@ -165,16 +164,27 @@ export function verifyConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.API_DUMP_CONFIG_AT_STARTUP) {
|
if (process.env.API_DUMP_CONFIG_AT_STARTUP) {
|
||||||
console.log("Dumping configuration:", JSON.stringify({
|
console.log(
|
||||||
...config,
|
'Dumping configuration:',
|
||||||
encryption: {
|
JSON.stringify(
|
||||||
...config.encryption,
|
{
|
||||||
key: config.encryption.key.slice(0, 4) + '[ REDACTED ]' + config.encryption.key.slice(-4),
|
...config,
|
||||||
},
|
encryption: {
|
||||||
jwt: {
|
...config.encryption,
|
||||||
secretOrKey: config.jwt.secretOrKey.slice(0, 4) + '[ REDACTED ]' + config.jwt.secretOrKey.slice(-4),
|
key:
|
||||||
}
|
config.encryption.key.slice(0, 4) + '[ REDACTED ]' + config.encryption.key.slice(-4),
|
||||||
}, null, 2))
|
},
|
||||||
|
jwt: {
|
||||||
|
secretOrKey:
|
||||||
|
config.jwt.secretOrKey.slice(0, 4) +
|
||||||
|
'[ REDACTED ]' +
|
||||||
|
config.jwt.secretOrKey.slice(-4),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -29,7 +29,7 @@ const params = {
|
||||||
app,
|
app,
|
||||||
passport,
|
passport,
|
||||||
...encryption(config.encryption.key),
|
...encryption(config.encryption.key),
|
||||||
config
|
config,
|
||||||
}
|
}
|
||||||
// Load routes
|
// Load routes
|
||||||
for (const type in routes) routes[type](params)
|
for (const type in routes) routes[type](params)
|
||||||
|
|
|
@ -22,7 +22,4 @@ function loadPassportMiddleware(passport, config) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { loadExpressMiddleware, loadPassportMiddleware }
|
||||||
loadExpressMiddleware,
|
|
||||||
loadPassportMiddleware,
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ const expect = chai.expect
|
||||||
chai.use(http)
|
chai.use(http)
|
||||||
|
|
||||||
describe('Non language-specific User controller signup routes', () => {
|
describe('Non language-specific User controller signup routes', () => {
|
||||||
|
|
||||||
it('Should return 400 on signup without body', (done) => {
|
it('Should return 400 on signup without body', (done) => {
|
||||||
chai
|
chai
|
||||||
.request(config.api)
|
.request(config.api)
|
||||||
|
@ -23,14 +22,20 @@ describe('Non language-specific User controller signup routes', () => {
|
||||||
let data = {
|
let data = {
|
||||||
email: 'test@freesewing.org',
|
email: 'test@freesewing.org',
|
||||||
language: 'en',
|
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) => {
|
it(`Should not create signup without ${key}`, (done) => {
|
||||||
chai
|
chai
|
||||||
.request(config.api)
|
.request(config.api)
|
||||||
.post('/signup')
|
.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) => {
|
.end((err, res) => {
|
||||||
expect(err === null).to.equal(true)
|
expect(err === null).to.equal(true)
|
||||||
expect(res.status).to.equal(400)
|
expect(res.status).to.equal(400)
|
||||||
|
@ -50,7 +55,7 @@ describe('Non language-specific User controller signup routes', () => {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
|
|
||||||
it('should not create signup without language', (done) => {
|
it('should not create signup without language', (done) => {
|
||||||
chai
|
chai
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue