Skip to content

Commit

Permalink
- Initial upload of nodejs-api-quickstart runtime with dockerfile and…
Browse files Browse the repository at this point in the history
… Pod YAML file for Kubernetes

- At the moment, it contains a basic route for getting the current date and time using Moment.js
  • Loading branch information
John Jardin john.jardin@ukuvuma.co.za committed Jan 23, 2018
1 parent 7f52949 commit d8dff66
Show file tree
Hide file tree
Showing 9 changed files with 507 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
nodejs-api-quickstart/node_modules
1 change: 1 addition & 0 deletions nodejs-api-quickstart/.env
@@ -0,0 +1 @@
DEPLOY_TYPE=production
5 changes: 5 additions & 0 deletions nodejs-api-quickstart/Dockerfile
@@ -0,0 +1,5 @@
FROM node:8.9.4-alpine
WORKDIR /nodejs-api-quickstart
ADD . /nodejs-api-quickstart
EXPOSE 3000
CMD npm start
17 changes: 17 additions & 0 deletions nodejs-api-quickstart/app.js
@@ -0,0 +1,17 @@
const http = require('http');
const bodyParser = require('body-parser');
const cors = require('cors');
const express = require('express');
const router = require('./router');
const app = express();
const port = process.env.PORT || 3000;

app.use(cors());
app.use(bodyParser.json());
router(app);

let server = http.createServer(app);

server.listen(port, function() {
console.log("NodeJS API Quickstart listening on Port: ", port);
});
7 changes: 7 additions & 0 deletions nodejs-api-quickstart/controllers/moment.js
@@ -0,0 +1,7 @@
const moment = require('moment');

const getCurrentDateTime = function(req, res){
return res.status(200).send(moment());
};

exports.getCurrentDateTime = getCurrentDateTime;

0 comments on commit d8dff66

Please sign in to comment.