Skip to content

Commit c77f7f5

Browse files
committed
Dev server is working
We want to get it to watch for changes next. This also removes some otherwise-unneeded dependencies.
1 parent 179f369 commit c77f7f5

File tree

3 files changed

+8
-46
lines changed

3 files changed

+8
-46
lines changed

package-lock.json

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "mocha --exit",
1010
"build": "babel src/ --out-dir=dist/ --copy-files",
1111
"dev": "concurrently --kill-others --prefix=name --names=server,eslint --prefix-colors=green,magenta \"npm run dev:server\" \"npm run dev:lint\"",
12-
"dev:server": "babel-watch --watch src test/server.js",
12+
"dev:server": "ts-node test/server.ts",
1313
"dev:lint": "esw src/ --changed --watch",
1414
"prepublishOnly": "npm run build"
1515
},
@@ -32,9 +32,7 @@
3232
"@types/node": "^11.13.4",
3333
"@types/serve-favicon": "^2.2.30",
3434
"chai": "^4.2.0",
35-
"colors": "^1.3.3",
3635
"concurrently": "^4.1.0",
37-
"find-port": "^2.0.1",
3836
"mocha": "^6.1.3",
3937
"serve-favicon": "^2.5.0",
4038
"supertest": "^4.0.2",

test/server.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
import express from 'express';
22
import path from 'path';
33
import favicon from 'serve-favicon';
4-
import findPort from 'find-port';
5-
import 'colors';
4+
5+
import avatarsRoutes from '../src/routes/avatars';
66

77
const app = express();
8-
const basePath = path.join(__dirname, '..');
9-
const faviconPath = path.join(basePath, 'src', 'favicon.ico');
8+
const port = Number(process.env.PORT) || 3002;
109

10+
const faviconPath = path.join(__dirname, '..', 'src', 'favicon.ico');
1111
app.use(favicon(faviconPath));
1212

13-
import avatarsRoutes from '../src/routes/avatars';
14-
1513
app.use('/avatars', avatarsRoutes);
1614

17-
const listen = (port) => {
18-
app.listen(port, function () {
19-
const { address } = this.address();
20-
console.log(`[Adorable Avatars] Running at: http://${address}:${port}`.green);
21-
});
22-
};
23-
24-
const port = Number(process.env.PORT) || 3002;
25-
26-
if (port > 3002) {
27-
listen(port);
28-
} else {
29-
findPort(port, port + 100, function(ports) {
30-
return listen(ports[0]);
31-
});
32-
}
15+
app.listen(port, () =>
16+
console.log(`[Adorable Avatars] Running at: http://localhost:${port}`)
17+
);
3318

3419
export default app;

0 commit comments

Comments
 (0)