Skip to content

Commit b254bee

Browse files
author
Abhinav Dhasmana
committed
Added server and its test case
1 parent cf5e771 commit b254bee

File tree

9 files changed

+4720
-346
lines changed

9 files changed

+4720
-346
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
env: {
33
es6: true,
44
node: true,
5+
jest: true
56
},
67
extends: [
78
'airbnb-base',

.github/main.workflow

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
workflow "npm build, lint, test and publish" {
2+
on = "push"
3+
4+
resolves = [
5+
"lint",
6+
"test"
7+
]
8+
}
9+
10+
action "build" {
11+
uses = "actions/npm@master"
12+
args = "install"
13+
}
14+
15+
action "lint" {
16+
needs = "build"
17+
uses = "actions/npm@master"
18+
args = "lint"
19+
}
20+
21+
action "test" {
22+
needs = "build"
23+
uses = "actions/npm@master"
24+
args = "test"
25+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
coverage

action-buildAndTest/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM debian:9.5-slim
2+
3+
LABEL "com.github.actions.name"="github actions example node"
4+
LABEL "com.github.actions.description"="A sample node.js application that uses github actions for CI and CD"
5+
LABEL "com.github.actions.icon"="mic"
6+
LABEL "com.github.actions.color"="purple"
7+
8+
LABEL "repository"="https://github.com/abhinavdhasmana/github-action-example-node"
9+
LABEL "maintainer"="Abhinav Dhasmana <[email protected]>"
10+
11+
ADD entrypoint.sh /entrypoint.sh
12+
ENTRYPOINT ["/entrypoint.sh"]

app.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const express = require('express');
2+
3+
const app = express();
4+
const createError = require('http-errors');
5+
6+
7+
app.use(express.json());
8+
app.use(express.urlencoded({ extended: false }));
9+
10+
app.use('/', (req, res) => res.send('Hello World!'));
11+
12+
// catch 404 and forward to error handler
13+
app.use((req, res, next) => {
14+
next(createError(404));
15+
});
16+
17+
// error handler
18+
app.use((err, req, res) => {
19+
// set locals, only providing error in development
20+
res.locals.message = err.message;
21+
res.locals.error = req.app.get('env') === 'development' ? err : {};
22+
23+
// render the error page
24+
res.status(err.status || 500);
25+
res.render('error');
26+
});
27+
module.exports = app;

0 commit comments

Comments
 (0)