Skip to content

Commit c901816

Browse files
Merge pull request #79 from BasicPrimitives/feathersjs
Removed dependency on feathersjs, upgraded packages to latest
2 parents dc23e03 + caf38db commit c901816

File tree

14 files changed

+819
-1567
lines changed

14 files changed

+819
-1567
lines changed

server/package.json

+8-23
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,21 @@
1616
"dev": "cross-env NODE_PATH=src NODE_ENV=development APIPORT=3030 node ./src/server.js"
1717
},
1818
"dependencies": {
19-
"@feathersjs/authentication": "^2.1.0",
20-
"@feathersjs/authentication-client": "^1.0.1",
21-
"@feathersjs/authentication-jwt": "^2.0.0",
22-
"@feathersjs/authentication-local": "^1.0.2",
23-
"@feathersjs/authentication-oauth2": "^1.0.2",
24-
"@feathersjs/errors": "^3.2.0",
25-
"@feathersjs/express": "^1.1.2",
26-
"@feathersjs/feathers": "^3.0.2",
27-
"@feathersjs/rest-client": "^1.3.2",
28-
"@feathersjs/socketio": "^3.0.1",
29-
"@feathersjs/socketio-client": "^1.0.1",
3019
"basicprimitives": "6.5.1",
31-
"compression": "^1.6.2",
32-
"cookie-parser": "^1.4.3",
20+
"compression": "^1.7.5",
21+
"cookie-parser": "^1.4.7",
3322
"cookies-js": "^1.2.3",
34-
"express": "^4.15.4",
35-
"express-session": "^1.15.5",
36-
"feathers-authentication-hooks": "^0.3.0",
37-
"feathers-hooks-common": "^4.10.0",
38-
"feathers-nedb": "^4.0.1",
23+
"express": "^4.21.1",
24+
"express-session": "^1.18.1",
3925
"hooks": "^0.3.2",
4026
"lodash": "^4.17.10",
4127
"memory-cache": "^0.2.0",
4228
"morgan": "^1.10.0",
43-
"nedb": "^1.8.0",
44-
"newrelic": "^7.1.0",
29+
"newrelic": "^12.8.0",
4530
"nprogress": "^0.2.0",
46-
"passport-facebook-token": "^3.3.0",
47-
"pretty-error": "^2.1.2",
48-
"util": "^0.12.0"
31+
"pretty-error": "^4.0.0",
32+
"util": "^0.12.0",
33+
"uuid": "^11.0.3"
4934
},
5035
"devDependencies": {
5136
"cross-env": "^7.0.2"

server/src/hooks/validateHook.js

-17
This file was deleted.

server/src/server.js

+18-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env node
2-
const express = require('@feathersjs/express');
3-
const feathers = require('@feathersjs/feathers');
2+
const express = require('express');
43
const morgan = require('morgan');
54
const session = require('express-session');
65
const bodyParser = require('body-parser');
76
const cookieParser = require('cookie-parser');
87
const PrettyError = require('pretty-error');
98
const config = require('./config');
10-
const services = require('./services');
9+
const services = require('./services'); // You may want to adjust or remove this if services rely on feathers
1110
require('newrelic');
1211

1312
const pretty = new PrettyError();
@@ -16,9 +15,9 @@ process.on('unhandledRejection', (reason, p) => {
1615
console.error('Unhandled Rejection at: Promise ', p, pretty.render(reason));
1716
});
1817

19-
const fApp = express(feathers());
18+
const app = express();
2019

21-
fApp.set('config', config)
20+
app.set('config', config)
2221
.use(morgan('dev'))
2322
.use(cookieParser())
2423
.use(
@@ -30,26 +29,21 @@ fApp.set('config', config)
3029
})
3130
)
3231
.use(bodyParser.urlencoded({ extended: true }))
33-
.use(bodyParser.json())
34-
// Core
35-
.configure(express.rest())
36-
.configure(services)
37-
// Final handlers
38-
.use(express.notFound())
39-
.use(
40-
express.errorHandler({
41-
logger: {
42-
error: error => {
43-
if (error && error.code !== 404) {
44-
console.error('API ERROR:', pretty.render(error));
45-
}
46-
}
47-
}
48-
})
49-
);
32+
.use(bodyParser.json());
5033

51-
const app = express();
52-
app.use('/api', fApp);
34+
services('/api', app);
35+
36+
// Final handlers
37+
app.use(express.static('public')); // Serve static files if needed
38+
app.use((req, res, next) => {
39+
res.status(404).send('Not Found');
40+
});
41+
app.use((error, req, res, next) => {
42+
if (error) {
43+
console.error('API ERROR:', pretty.render(error));
44+
res.status(500).send('Internal Server Error');
45+
}
46+
});
5347

5448
if (process.env.APIPORT) {
5549
app.listen(process.env.APIPORT, err => {

server/src/services/authentication/index.js

-41
This file was deleted.

server/src/services/demofamilycharts/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const financialOwnership = require('./data/financialOwnership.js');
2424
const mutualFinancialOwnership = require('./data/mutualFinancialOwnership.js');
2525
const techTree = require('./data/techTree.js');
2626

27-
function service(app) {
28-
app.use('/load-demofamilychartslist', (req, res) => {
27+
function service(folder, app) {
28+
app.use(`${folder}/load-demofamilychartslist`, (req, res) => {
2929
const names = {
3030
'2 Cross Relations': 'crossShape',
3131
'3 Cross Relations': 'famdata2',
@@ -49,7 +49,7 @@ function service(app) {
4949
return res.json(names);
5050
});
5151

52-
app.use('/load-demofamilychart', (req, res) => {
52+
app.use(`${folder}/load-demofamilychart`, (req, res) => {
5353
let result = { message: `Chart ${req.name} not found!` };
5454

5555
const { name } = req.query;

server/src/services/demoorganizationalcharts/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const CrossBranchAlignment = require('./data/crossbranchalignment.js');
55
const MatrixLayout = require('./data/matrixlayout.js');
66
const VerticalLayoutOrganizationalChart = require('./data/verticallayoutorganizationalchart.js');
77

8-
function service(app) {
9-
app.use('/load-demoorganizationalchart', (req, res) => {
8+
function service(url, app) {
9+
app.use(`${url}/load-demoorganizationalchart`, (req, res) => {
1010
let result = { message: `Chart ${req.name} not found!` };
1111

1212
const { name } = req.query;

server/src/services/howtouse/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const newrelic = require('newrelic');
77
const { loadMarkdown, getSampleFileContent } = require('./markdown');
88
const { URL } = require('url');
99

10-
module.exports = function customService(app) {
11-
app.use('/load-markdown', async (req, res, next) => {
10+
module.exports = function customService(folder, app) {
11+
app.use(`${folder}/load-markdown`, async (req, res, next) => {
1212
let gclid = null;
1313
if(req.headers.referer != null) {
1414
let url = new URL(req.headers.referer);
@@ -28,32 +28,32 @@ module.exports = function customService(app) {
2828
}
2929
});
3030

31-
app.use('/get-sample', async (req, res) => {
31+
app.use(`${folder}/get-sample`, async (req, res) => {
3232
const fileContent = await getSampleFileContent(req.query.name);
3333
return res.send(fileContent);
3434
});
3535

36-
app.use('/get-saved-sample', (req, res) => {
36+
app.use(`${folder}/get-saved-sample`, (req, res) => {
3737
let fileContent = cache.get(req.query.name);
3838
if (fileContent == null) {
3939
fileContent = '<p>Sample expired in cache. Click Try button again.</p>';
4040
}
4141
return res.send(fileContent);
4242
});
4343

44-
app.use('/save-code', (req, res) => {
44+
app.use(`${folder}/save-code`, (req, res) => {
4545
const id = uuid.v1();
4646
cache.put(id, req.body.content, 60000);
4747
return res.json({
4848
url: `/api/get-saved-sample?name=${id}`
4949
});
5050
});
5151

52-
app.use('/images', express.static(path.join(__dirname, '..', '..', 'static', 'javascript', 'samples', 'images')));
53-
app.use('/images', express.static(path.join(__dirname, '..', '..', 'static', 'react', 'docs', 'images')));
54-
app.use('/javascript', express.static(path.join(__dirname, '..', '..', 'static', 'javascript')));
55-
app.use('/javascript', express.static(path.join(__dirname, '..', '..', 'static', 'javascript' , 'dist')));
56-
app.use('/javascript', express.static(path.join(__dirname, '..', '..', 'static', 'javascript')));
57-
app.use('/data', express.static(path.join(__dirname, '..', '..', 'static', 'javascript', 'samples', 'data')));
58-
app.use('/', express.static(path.join(__dirname, '..', '..', 'static')));
52+
app.use(`${folder}/images`, express.static(path.join(__dirname, '..', '..', 'static', 'javascript', 'samples', 'images')));
53+
app.use(`${folder}/images`, express.static(path.join(__dirname, '..', '..', 'static', 'react', 'docs', 'images')));
54+
app.use(`${folder}/javascript`, express.static(path.join(__dirname, '..', '..', 'static', 'javascript')));
55+
app.use(`${folder}/javascript`, express.static(path.join(__dirname, '..', '..', 'static', 'javascript' , 'dist')));
56+
app.use(`${folder}/javascript`, express.static(path.join(__dirname, '..', '..', 'static', 'javascript')));
57+
app.use(`${folder}/data`, express.static(path.join(__dirname, '..', '..', 'static', 'javascript', 'samples', 'data')));
58+
app.use(`${folder}/`, express.static(path.join(__dirname, '..', '..', 'static')));
5959
}

server/src/services/index.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
const authentication = require('./authentication');
1+
// const authentication = require('./authentication');
22
const demoorganizationalcharts = require('./demoorganizationalcharts');
33
const demofamilycharts = require('./demofamilycharts');
44
const howtouse = require('./howtouse');
5-
const users = require('./users');
65

7-
function services(app) {
8-
app.configure(authentication);
9-
app.configure(demoorganizationalcharts);
10-
app.configure(demofamilycharts);
11-
app.configure(users);
12-
app.configure(howtouse);
6+
function services(url, app) {
7+
// app.configure(authentication);
8+
demoorganizationalcharts(url, app);
9+
demofamilycharts(url, app);
10+
howtouse(url, app);
1311
};
1412

1513
module.exports = services;

server/src/services/users/hooks.js

-47
This file was deleted.

server/src/services/users/index.js

-20
This file was deleted.

server/src/services/users/users.nedb

Whitespace-only changes.

server/src/static/javascript

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit cad96c285d38b147b53cd57d56472284e0eb14a8
1+
Subproject commit ef025dfc8564f04e31cda3bd329e0893616e8717

server/src/static/react

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit f9e7e5f34a392f09dacd1f07f5482ab02896f23b
1+
Subproject commit 2832afa9c64356f282b0104b32076f19e2f3370c

0 commit comments

Comments
 (0)