Skip to content

Commit 2b91f3a

Browse files
committedMar 21, 2020
refactor(server): move index.js and app.js to /server
1 parent 275106e commit 2b91f3a

14 files changed

+20
-30
lines changed
 

‎.nycrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"all": true,
3-
"include": ["dist/server/**/*.js", "dist/index.js", "dist/app.js"],
3+
"include": ["dist/server/**/*.js"],
44
"excludeAfterRemap": false
55
}

‎Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COPY public ./public
1515
COPY preact.config.js ./
1616

1717
COPY server ./server
18-
COPY tsconfig.json index.js app.js ./
18+
COPY tsconfig.json ./
1919

2020
RUN yarn && yarn build && rm -rf node_modules
2121

@@ -28,4 +28,4 @@ EXPOSE 8000
2828
COPY . .
2929

3030

31-
CMD ["node", "dist/index.js"]
31+
CMD ["node", "dist/server/index.js"]

‎package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
22
"name": "rctf",
33
"version": "0.0.0",
4-
"main": "index.js",
54
"license": "MIT",
65
"private": true,
76
"scripts": {
87
"lint": "tsc --noEmit && eslint --ext .js,.ts .",
9-
"start": "node dist/index.js",
8+
"start": "node dist/server/index.js",
109
"migrate": "node-pg-migrate --database-url-var=RCTF_DATABASE_URL",
1110
"build:client": "sh client/build.sh",
1211
"build:ts": "tsc && yarn copy-static",
1312
"build": "yarn build:ts && yarn build:client",
1413
"watch:client": "preact watch --src client/src --template client/index.html",
15-
"watch:server": "nodemon dist/index.js",
14+
"watch:server": "nodemon dist/server/index.js",
1615
"watch:ts": "tsc -w",
1716
"dev": "yarn build:ts && concurrently -k -t \"HH:mm:ss.SSS\" -p \"[{time}]\" -c \"cyan,green,red\" \"yarn:watch:*\"",
1817
"test": "yarn build && nyc --skip-full ava",
1918
"test:report": "nyc --skip-full --reporter=lcov ava",
20-
"copy-static": "cpy 'server/**/*' '.rdeploy' '!**/*.ts' dist/ --no-overwrite --parents"
19+
"copy-static": "sh -c \"cpy 'server/**/*' '.rdeploy' '!**/*.ts' dist/ --no-overwrite --parents\""
2120
},
2221
"husky": {
2322
"hooks": {

‎server/.eslintrc.js

-9
This file was deleted.

‎app.js renamed to ‎server/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const path = require('path')
22
const express = require('express')
3-
const { enableCORS, serveDownloads } = require('./server/util')
3+
const { enableCORS, serveDownloads } = require('./util')
44

5-
require('./server/leaderboard').startUpdater()
5+
require('./leaderboard').startUpdater()
66

77
const app = express()
88

@@ -20,9 +20,9 @@ app.use(express.raw({
2020
type: 'application/json'
2121
}))
2222

23-
app.use('/api/v1', require('./server/api'))
23+
app.use('/api/v1', require('./api'))
2424

25-
const staticPath = path.join(__dirname, '/build')
25+
const staticPath = path.join(__dirname, '../build')
2626
app.use(express.static(staticPath, { extensions: ['html'] }))
2727
app.use(serveDownloads('/static/files'))
2828
app.use((req, res, next) => {
File renamed without changes.

‎test/integration/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.serial('PORT env flag', async t => {
1111
const old = process.env.PORT
1212
process.env.PORT = PORT
1313

14-
require(path.join(__dirname, '/../../dist/index'))
14+
require(path.join(__dirname, '/../../dist/server/index'))
1515

1616
const resp = await got(`http://localhost:${PORT}`)
1717
t.true(resp.body !== undefined)
@@ -23,12 +23,12 @@ test.serial('TEST_COMPRESSION env flag', async t => {
2323
const old = process.env.TEST_COMPRESSION
2424
process.env.TEST_COMPRESSION = '1'
2525

26-
const resp = await request(reloadModule(path.join(__dirname, '/../../dist/app')))
26+
const resp = await request(reloadModule(path.join(__dirname, '/../../dist/server/app')))
2727
.get('/favicon.ico')
2828
.expect('Content-Encoding', /gzip/)
2929

3030
t.true(resp.body !== undefined)
3131

3232
process.env.TEST_COMPRESSION = old
33-
reloadModule(path.join(__dirname, '/../../dist/app'))
33+
reloadModule(path.join(__dirname, '/../../dist/server/app'))
3434
})

‎test/integration/auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44
const { removeUserByEmail } = require('../../dist/server/database').auth
55

66
const config = require('../../dist/config/server')

‎test/integration/challenges.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44
const { v4: uuidv4 } = require('uuid')
55
const auth = require('../../dist/server/auth')
66
const config = require('../../dist/config/server')

‎test/integration/leaderboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44

55
const { responseList } = require('../../dist/server/responses')
66

‎test/integration/profile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44
const { v4: uuidv4 } = require('uuid')
55

66
const config = require('../../dist/config/server')

‎test/integration/submit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44
const { v4: uuidv4 } = require('uuid')
55

66
const db = require('../../dist/server/database')

‎test/integration/submitTiming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava')
22
const request = require('supertest')
3-
const app = require('../../dist/app')
3+
const app = require('../../dist/server/app')
44
const config = require('../../dist/config/server')
55
const { v4: uuidv4 } = require('uuid')
66

‎tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"baseUrl": "."
1414
},
1515
"include": [
16-
"src/**/*", "index.js", "app.js"
16+
"server/**/*"
1717
]
1818
}

0 commit comments

Comments
 (0)
Please sign in to comment.