Showing
10 changed files
with
274 additions
and
0 deletions
.gitignore
0 → 100644
1 | + | ||
2 | +# Created by https://www.gitignore.io/api/node | ||
3 | + | ||
4 | +### Node ### | ||
5 | +# Logs | ||
6 | +logs | ||
7 | +*.log | ||
8 | +npm-debug.log* | ||
9 | +yarn-debug.log* | ||
10 | +yarn-error.log* | ||
11 | + | ||
12 | +# Runtime data | ||
13 | +pids | ||
14 | +*.pid | ||
15 | +*.seed | ||
16 | +*.pid.lock | ||
17 | + | ||
18 | +# Directory for instrumented libs generated by jscoverage/JSCover | ||
19 | +lib-cov | ||
20 | + | ||
21 | +# Coverage directory used by tools like istanbul | ||
22 | +coverage | ||
23 | + | ||
24 | +# nyc test coverage | ||
25 | +.nyc_output | ||
26 | + | ||
27 | +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
28 | +.grunt | ||
29 | + | ||
30 | +# Bower dependency directory (https://bower.io/) | ||
31 | +bower_components | ||
32 | + | ||
33 | +# node-waf configuration | ||
34 | +.lock-wscript | ||
35 | + | ||
36 | +# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
37 | +build/Release | ||
38 | + | ||
39 | +# Dependency directories | ||
40 | +node_modules/ | ||
41 | +jspm_packages/ | ||
42 | +kakao_option.js | ||
43 | +db_option.js | ||
44 | +session.js | ||
45 | +kakao_option.js | ||
46 | +# TypeScript v1 declaration files | ||
47 | +typings/ | ||
48 | + | ||
49 | +# Optional npm cache directory | ||
50 | +.npm | ||
51 | + | ||
52 | +# Optional eslint cache | ||
53 | +.eslintcache | ||
54 | + | ||
55 | +# Optional REPL history | ||
56 | +.node_repl_history | ||
57 | + | ||
58 | +# Output of 'npm pack' | ||
59 | +*.tgz | ||
60 | + | ||
61 | +# Yarn Integrity file | ||
62 | +.yarn-integrity | ||
63 | + | ||
64 | +# dotenv environment variables file | ||
65 | +.env | ||
66 | + | ||
67 | +# parcel-bundler cache (https://parceljs.org/) | ||
68 | +.cache | ||
69 | + | ||
70 | +# next.js build output | ||
71 | +.next | ||
72 | + | ||
73 | +# nuxt.js build output | ||
74 | +.nuxt | ||
75 | + | ||
76 | +# vuepress build output | ||
77 | +.vuepress/dist | ||
78 | + | ||
79 | +# Serverless directories | ||
80 | +.serverless | ||
81 | + | ||
82 | + | ||
83 | +# End of https://www.gitignore.io/api/node | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
app.js
0 → 100644
1 | +var createError = require('http-errors'); | ||
2 | +var express = require('express'); | ||
3 | +var path = require('path'); | ||
4 | +var cookieParser = require('cookie-parser'); | ||
5 | +var logger = require('morgan'); | ||
6 | + | ||
7 | +var indexRouter = require('./routes/index'); | ||
8 | +var usersRouter = require('./routes/users'); | ||
9 | + | ||
10 | +var app = express(); | ||
11 | + | ||
12 | +// view engine setup | ||
13 | +app.set('views', path.join(__dirname, 'views')); | ||
14 | +app.set('view engine', 'ejs'); | ||
15 | + | ||
16 | +app.use(logger('dev')); | ||
17 | +app.use(express.json()); | ||
18 | +app.use(express.urlencoded({ extended: false })); | ||
19 | +app.use(cookieParser()); | ||
20 | +app.use(express.static(path.join(__dirname, 'public'))); | ||
21 | + | ||
22 | +app.use('/', indexRouter); | ||
23 | +app.use('/users', usersRouter); | ||
24 | + | ||
25 | +// catch 404 and forward to error handler | ||
26 | +app.use(function(req, res, next) { | ||
27 | + next(createError(404)); | ||
28 | +}); | ||
29 | + | ||
30 | +// error handler | ||
31 | +app.use(function(err, req, res, next) { | ||
32 | + // set locals, only providing error in development | ||
33 | + res.locals.message = err.message; | ||
34 | + res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
35 | + | ||
36 | + // render the error page | ||
37 | + res.status(err.status || 500); | ||
38 | + res.render('error'); | ||
39 | +}); | ||
40 | + | ||
41 | +module.exports = app; |
bin/www
0 → 100644
1 | +#!/usr/bin/env node | ||
2 | + | ||
3 | +/** | ||
4 | + * Module dependencies. | ||
5 | + */ | ||
6 | + | ||
7 | +var app = require('../app'); | ||
8 | +var debug = require('debug')('project:server'); | ||
9 | +var http = require('http'); | ||
10 | + | ||
11 | +/** | ||
12 | + * Get port from environment and store in Express. | ||
13 | + */ | ||
14 | + | ||
15 | +var port = normalizePort(process.env.PORT || '3000'); | ||
16 | +app.set('port', port); | ||
17 | + | ||
18 | +/** | ||
19 | + * Create HTTP server. | ||
20 | + */ | ||
21 | + | ||
22 | +var server = http.createServer(app); | ||
23 | + | ||
24 | +/** | ||
25 | + * Listen on provided port, on all network interfaces. | ||
26 | + */ | ||
27 | + | ||
28 | +server.listen(port); | ||
29 | +server.on('error', onError); | ||
30 | +server.on('listening', onListening); | ||
31 | + | ||
32 | +/** | ||
33 | + * Normalize a port into a number, string, or false. | ||
34 | + */ | ||
35 | + | ||
36 | +function normalizePort(val) { | ||
37 | + var port = parseInt(val, 10); | ||
38 | + | ||
39 | + if (isNaN(port)) { | ||
40 | + // named pipe | ||
41 | + return val; | ||
42 | + } | ||
43 | + | ||
44 | + if (port >= 0) { | ||
45 | + // port number | ||
46 | + return port; | ||
47 | + } | ||
48 | + | ||
49 | + return false; | ||
50 | +} | ||
51 | + | ||
52 | +/** | ||
53 | + * Event listener for HTTP server "error" event. | ||
54 | + */ | ||
55 | + | ||
56 | +function onError(error) { | ||
57 | + if (error.syscall !== 'listen') { | ||
58 | + throw error; | ||
59 | + } | ||
60 | + | ||
61 | + var bind = typeof port === 'string' | ||
62 | + ? 'Pipe ' + port | ||
63 | + : 'Port ' + port; | ||
64 | + | ||
65 | + // handle specific listen errors with friendly messages | ||
66 | + switch (error.code) { | ||
67 | + case 'EACCES': | ||
68 | + console.error(bind + ' requires elevated privileges'); | ||
69 | + process.exit(1); | ||
70 | + break; | ||
71 | + case 'EADDRINUSE': | ||
72 | + console.error(bind + ' is already in use'); | ||
73 | + process.exit(1); | ||
74 | + break; | ||
75 | + default: | ||
76 | + throw error; | ||
77 | + } | ||
78 | +} | ||
79 | + | ||
80 | +/** | ||
81 | + * Event listener for HTTP server "listening" event. | ||
82 | + */ | ||
83 | + | ||
84 | +function onListening() { | ||
85 | + var addr = server.address(); | ||
86 | + var bind = typeof addr === 'string' | ||
87 | + ? 'pipe ' + addr | ||
88 | + : 'port ' + addr.port; | ||
89 | + debug('Listening on ' + bind); | ||
90 | +} |
package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
package.json
0 → 100644
1 | +{ | ||
2 | + "name": "project", | ||
3 | + "version": "0.0.0", | ||
4 | + "private": true, | ||
5 | + "scripts": { | ||
6 | + "start": "node ./bin/www" | ||
7 | + }, | ||
8 | + "dependencies": { | ||
9 | + "body-parser": "^1.18.3", | ||
10 | + "compression": "^1.7.3", | ||
11 | + "cookie-parser": "~1.4.3", | ||
12 | + "debug": "~2.6.9", | ||
13 | + "ejs": "~2.5.7", | ||
14 | + "express": "~4.16.0", | ||
15 | + "http-errors": "~1.6.2", | ||
16 | + "morgan": "~1.9.0", | ||
17 | + "helmet": "^3.13.0", | ||
18 | + "socket.io": "^2.1.1" | ||
19 | + } | ||
20 | +} |
public/stylesheets/style.css
0 → 100644
routes/index.js
0 → 100644
routes/users.js
0 → 100644
views/error.ejs
0 → 100644
-
Please register or login to post a comment