Skip to content

Commit 08c0afc

Browse files
committed
added new bookstore example
1 parent e3ee860 commit 08c0afc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3599
-1873
lines changed

bookstore/app.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
var apiRouter = require('./routes/api');
10+
11+
var app = express();
12+
13+
// CORS
14+
if (process.env.NODE_ENV === 'development') {
15+
var cors = require('cors');
16+
app.use(cors());
17+
}
18+
19+
// view engine setup
20+
app.set('views', path.join(__dirname, 'views'));
21+
app.set('view engine', 'jade');
22+
23+
app.use(logger('dev'));
24+
app.use(express.json());
25+
app.use(express.urlencoded({ extended: false }));
26+
app.use(cookieParser());
27+
app.use(express.static(path.join(__dirname, 'public')));
28+
29+
app.use('/', indexRouter);
30+
app.use('/users', usersRouter);
31+
app.use('/api', apiRouter);
32+
33+
// catch 404 and forward to error handler
34+
app.use(function(req, res, next) {
35+
next(createError(404));
36+
});
37+
38+
// error handler
39+
app.use(function(err, req, res, next) {
40+
// set locals, only providing error in development
41+
res.locals.message = err.message;
42+
res.locals.error = req.app.get('env') === 'development' ? err : {};
43+
44+
// render the error page
45+
res.status(err.status || 500);
46+
res.render('error');
47+
});
48+
49+
module.exports = app;

bookstore/bin/www

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
var app = require('../app');
8+
var debug = require('debug')('sample-site: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+
}

bookstore/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "sample-site",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"start": "node ./bin/www",
7+
"build": "cd react-site && npm run build && cd .. && cp -R react-site/build/ public/ && mv public/index.html public/app.html",
8+
"dev": "concurrently \"NODE_ENV=development PORT=3000 nodemon\" \" cd react-site && PORT=3001 npm run start\""
9+
},
10+
"dependencies": {
11+
"axios": "^0.21.0",
12+
"cloudcms": "file:../cloudcms-javascript-driver",
13+
"concurrently": "^5.3.0",
14+
"cookie-parser": "~1.4.4",
15+
"cors": "^2.8.5",
16+
"debug": "~2.6.9",
17+
"express": "~4.16.1",
18+
"http-errors": "~1.6.3",
19+
"jade": "~1.11.0",
20+
"morgan": "~1.9.1",
21+
"nodemon": "^2.0.6",
22+
"react-router": "^5.2.0",
23+
"react-router-dom": "^5.2.0"
24+
}
25+
}

bookstore/public/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><link href="/static/css/main.6dea0f05.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,i,a=t[0],c=t[1],l=t[2],s=0,p=[];s<a.length;s++)i=a[s],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(t);p.length;)p.shift()();return u.push.apply(u,l||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,a=1;a<r.length;a++){var c=r[a];0!==o[c]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={1:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"eee614bf"}[e]+".chunk.js"}(e);var c=new Error;u=function(t){a.onerror=a.onload=null,clearTimeout(l);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,r[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=this["webpackJsonpreact-site"]=this["webpackJsonpreact-site"]||[],c=a.push.bind(a);a.push=t,a=a.slice();for(var l=0;l<a.length;l++)t(a[l]);var f=c;r()}([])</script><script src="/static/js/2.188934cb.chunk.js"></script><script src="/static/js/main.06ccd071.chunk.js"></script></body></html>

bookstore/public/asset-manifest.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"files": {
3+
"main.css": "/static/css/main.6dea0f05.chunk.css",
4+
"main.js": "/static/js/main.06ccd071.chunk.js",
5+
"main.js.map": "/static/js/main.06ccd071.chunk.js.map",
6+
"runtime-main.js": "/static/js/runtime-main.2071cbbc.js",
7+
"runtime-main.js.map": "/static/js/runtime-main.2071cbbc.js.map",
8+
"static/js/2.188934cb.chunk.js": "/static/js/2.188934cb.chunk.js",
9+
"static/js/2.188934cb.chunk.js.map": "/static/js/2.188934cb.chunk.js.map",
10+
"static/js/3.eee614bf.chunk.js": "/static/js/3.eee614bf.chunk.js",
11+
"static/js/3.eee614bf.chunk.js.map": "/static/js/3.eee614bf.chunk.js.map",
12+
"index.html": "/index.html",
13+
"static/css/main.6dea0f05.chunk.css.map": "/static/css/main.6dea0f05.chunk.css.map",
14+
"static/js/2.188934cb.chunk.js.LICENSE.txt": "/static/js/2.188934cb.chunk.js.LICENSE.txt"
15+
},
16+
"entrypoints": [
17+
"static/js/runtime-main.2071cbbc.js",
18+
"static/js/2.188934cb.chunk.js",
19+
"static/css/main.6dea0f05.chunk.css",
20+
"static/js/main.06ccd071.chunk.js"
21+
]
22+
}

bookstore/public/favicon.ico

3.78 KB
Binary file not shown.

bookstore/public/logo192.png

5.22 KB
Loading

bookstore/public/logo512.png

9.44 KB
Loading

bookstore/public/manifest.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

bookstore/public/robots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

bookstore/public/static/css/main.6dea0f05.chunk.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bookstore/public/static/css/main.6dea0f05.chunk.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bookstore/public/static/js/2.188934cb.chunk.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
object-assign
3+
(c) Sindre Sorhus
4+
@license MIT
5+
*/
6+
7+
/** @license React v0.20.1
8+
* scheduler.production.min.js
9+
*
10+
* Copyright (c) Facebook, Inc. and its affiliates.
11+
*
12+
* This source code is licensed under the MIT license found in the
13+
* LICENSE file in the root directory of this source tree.
14+
*/
15+
16+
/** @license React v17.0.1
17+
* react-dom.production.min.js
18+
*
19+
* Copyright (c) Facebook, Inc. and its affiliates.
20+
*
21+
* This source code is licensed under the MIT license found in the
22+
* LICENSE file in the root directory of this source tree.
23+
*/
24+
25+
/** @license React v17.0.1
26+
* react-jsx-runtime.production.min.js
27+
*
28+
* Copyright (c) Facebook, Inc. and its affiliates.
29+
*
30+
* This source code is licensed under the MIT license found in the
31+
* LICENSE file in the root directory of this source tree.
32+
*/
33+
34+
/** @license React v17.0.1
35+
* react.production.min.js
36+
*
37+
* Copyright (c) Facebook, Inc. and its affiliates.
38+
*
39+
* This source code is licensed under the MIT license found in the
40+
* LICENSE file in the root directory of this source tree.
41+
*/

bookstore/public/static/js/2.188934cb.chunk.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bookstore/public/static/js/3.eee614bf.chunk.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)