Skip to content

Commit 47c88f7

Browse files
committed
Add GET /ping handler
1 parent b2f573b commit 47c88f7

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

server/apis/ping.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const file = 'server/apis/ping.js';
2+
3+
export default (app) => {
4+
app.get('/ping', (req, res) => {
5+
req.log.info({ file, function:'default', req: { url: req.url } });
6+
7+
res.send('pong');
8+
});
9+
};

server/app.js

+2-21
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ var path = require('path');
55

66
import bodyParser from 'body-parser';
77
import expressRequestId from 'express-request-id';
8-
9-
import auth from './apis/auth';
108
import logger from './libs/logger';
9+
import ping from './apis/ping';
1110
import session from './libs/session';
12-
import userMiddleware from './libs/userMiddleware';
13-
14-
const file = 'server/app.js';
1511

1612
const app = express();
1713

@@ -21,22 +17,7 @@ app.use(session.createSessionMiddleware());
2117
app.use(logger);
2218
app.use(express.static(path.join(__dirname, './public')));
2319

24-
app.post('/signin', (req, res) => {
25-
req.log.info({ file, function:'post', req: { url: req.url } });
26-
27-
auth.signin(req)
28-
.then((result) => res.send(result))
29-
.catch((error) => {
30-
req.log.info({ file, function: 'post', error });
31-
res.status(403).send(error);
32-
});
33-
});
34-
35-
app.post('/signout', (req, res) => {
36-
req.log.info({ function:'app.post', req: { url: req.url } });
37-
38-
res.send(auth.signout(req, res));
39-
});
20+
ping(app);
4021

4122
// Export your express server so you can import it in the lambda function.
4223
module.exports = app;

0 commit comments

Comments
 (0)