-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
184 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ node_modules | |
dist | ||
.idea | ||
application.log | ||
static/files/* | ||
cache_temp/* | ||
static_temp/* | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
const express = require('express'); | ||
const logger = require('morgan'); | ||
var createError = require('http-errors'); | ||
var express = require('express'); | ||
var path = require('path'); | ||
var logger = require('morgan'); | ||
|
||
const app = express(); | ||
var indexRouter = require('./routes/index'); | ||
|
||
app.get('/', (req, res) => { | ||
res.send('Hello CMS!') | ||
var app = express(); | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'jade'); | ||
|
||
app.use(logger('dev')); | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: false })); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use('/', indexRouter); | ||
|
||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
next(createError(404)); | ||
}); | ||
|
||
// error handler | ||
app.use(function(err, req, res, next) { | ||
// set locals, only providing error in development | ||
res.locals.message = err.message; | ||
res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
|
||
// render the error page | ||
res.status(err.status || 500); | ||
res.render('error'); | ||
}); | ||
|
||
app.listen(3000, () => { | ||
console.log('Server started and listening on PORT: 3000'); | ||
}); | ||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require('../app'); | ||
var debug = require('debug')('cms-backend:server'); | ||
var http = require('http'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort(process.env.PORT || '3000'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,15 @@ | ||
{ | ||
"name": "cms-backend-api", | ||
"version": "1.0.0", | ||
"description": "Simple CMS backend", | ||
"main": "app.js", | ||
"name": "cms-backend", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "node app.js", | ||
"test": "mocha" | ||
"start": "node ./bin/www" | ||
}, | ||
"author": "Satyajit Dey<satyajit@cefalo.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Ahmed Maruf", | ||
"email": "maruf@cefalo.com" | ||
}, | ||
{ | ||
"name": "Atiqul Alama", | ||
"email": "atiqul@cefalo.com" | ||
}, | ||
{ | ||
"name": "Rezaul Karim", | ||
"email": "tito@cefalo.com" | ||
}, | ||
{ | ||
"name": "Satyajit Dey", | ||
"email": "satyajit@cefalo.com" | ||
} | ||
], | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "4.17.1", | ||
"morgan": "1.10.0", | ||
"passport": "0.4.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "6.8.0", | ||
"mocha": "7.1.2", | ||
"nodemon": "2.0.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Cefalo/cms-backend-api.git" | ||
"debug": "~2.6.9", | ||
"express": "~4.16.1", | ||
"http-errors": "~1.6.3", | ||
"jade": "~1.11.0", | ||
"morgan": "~1.9.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
body { | ||
padding: 50px; | ||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
a { | ||
color: #00B7FF; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.render('index', { title: 'Cefalo CMS' }); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends layout | ||
|
||
block content | ||
h1 #{error.status} #{message} | ||
pre #{error.stack} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
doctype html | ||
html | ||
head | ||
title= title | ||
style(type='text/css'). | ||
html,body{height:100%}body{display: table;margin: 0 auto;font-size:3em;text-align: center}div{text-align:left;display: table-cell;vertical-align: middle} | ||
|
||
body | ||
div | ||
pre | ||
| /~\ | ||
| |oo ) Hello World! | ||
| _\=/_ | ||
| ___ / _ \ | ||
| / ()\ //|/.\|\\ | ||
| _|_____|_ \\ \_/ || | ||
| | | === | | \|\ /| || | ||
| |_| O |_| # _ _/ # | ||
| || O || | | | | ||
| ||__*__|| | | | | ||
| |~ \___/ ~| []|[] | ||
| /=\ /=\ /=\ | | | | ||
|_____[_]_[_]_[_]________/_]_[_\____________ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
doctype html | ||
html | ||
head | ||
title= title | ||
link(rel='stylesheet', href='/css/style.css') | ||
body | ||
block content |