Skip to content

Commit 984d00b

Browse files
committed
Setup production environtment
1 parent a76be19 commit 984d00b

File tree

8 files changed

+59
-39
lines changed

8 files changed

+59
-39
lines changed

config/production.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
2-
"host": "server-app.feathersjs.com",
3-
"port": "PORT"
2+
"host": "HOST",
3+
"port": "PORT",
4+
"postgres": {
5+
"connection": "DATABASE_URL",
6+
"ssl": {
7+
"required": true,
8+
"rejectUnauthorized": false
9+
}
10+
},
11+
"vapid": {
12+
"publicKey": "VAPID_PUBLIC_KEY",
13+
"privateKey": "VAPID_PRIVATE_KEY",
14+
"subject": "VAPID_SUBJECT"
15+
}
416
}

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"npm": ">= 3.0.0"
2525
},
2626
"scripts": {
27+
"install:public": "cd public && npm install",
28+
"build:public": "cd public && npm run build",
29+
"postinstall": "npm run install:public",
30+
"postbuild": "npm run build:public",
31+
"build": "npm run lint",
2732
"test": "npm run lint && npm run mocha",
2833
"lint": "eslint src/. test/. --config .eslintrc.json --fix",
2934
"dev": "nodemon src/",

public/.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
REACT_APP_VAPID_KEY = BGRhvbXYp6YIfMXWu1oqU7pvPnFcxYXTmCBzxE19ObWLlXzMN32aeUHHKZQ2_Do4kkC2JiQTWytZpTunOTFOqzQ
1+
REACT_APP_VAPID_KEY = BGRhvbXYp6YIfMXWu1oqU7pvPnFcxYXTmCBzxE19ObWLlXzMN32aeUHHKZQ2_Do4kkC2JiQTWytZpTunOTFOqzQ
2+
REACT_APP_SERVER_ORIGIN = http://localhost:3030

public/src/components/Client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import feathersjs from "@feathersjs/feathers";
44
import socketio from "@feathersjs/socketio-client";
55
import authentication from "@feathersjs/authentication-client";
66

7-
const socket = io("http://localhost:3030");
7+
const url = new URL(process["env"]["REACT_APP_SERVER_ORIGIN"]);
8+
9+
const socket = io(url.toString());
810
const feathers = feathersjs();
911

1012
feathers.configure(socketio(socket));

src/services/devices/devices.class.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ const { Service } = require('feathers-sequelize');
33
exports.Devices = class Devices extends Service {
44
async create(data, params) {
55
const defaultValue = {
6-
label: `device-${data["id"]}${Date.now()}`,
6+
label: `device-${data['id']}${Date.now()}`,
77
config: {
88
medicine: {
99
lvl1: {
10-
name: "",
11-
time: ""
10+
name: '',
11+
time: ''
1212
},
1313
lvl2: {
14-
name: "",
15-
time: ""
14+
name: '',
15+
time: ''
1616
},
1717
lvl3: {
18-
name: "",
19-
time: ""
18+
name: '',
19+
time: ''
2020
}
2121
}
2222
},
2323
connectionStatus: false,
2424
...data
25-
}
25+
};
2626
return super.create(defaultValue, params);
2727
}
2828
};

src/services/patient/patient.class.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ exports.Patient = class Patient extends Service {
99
async remove(id, params) {
1010
const patient = await this.get(id);
1111
const ret = await super.remove(id, params);
12-
if (patient["device.id"]) {
13-
await this.app.service("devices").remove(patient["device.id"]);
12+
if (patient['device.id']) {
13+
await this.app.service('devices').remove(patient['device.id']);
1414
}
1515
return ret;
1616
}
1717

1818
async create(data, params) {
1919
let ret = await super.create(data, params);
2020

21-
const device = await this.app.service("devices").create({
22-
patientId: ret["id"]
21+
const device = await this.app.service('devices').create({
22+
patientId: ret['id']
2323
});
2424

25-
console.log("device created", device);
25+
console.log('device created', device);
2626
return ret;
2727
}
2828
async get(id, params) {
2929
let ret = await super.get(id, {
3030
...params,
3131
sequelize: {
3232
include: [{
33-
model: this.app.service("devices").Model,
34-
as: "device"
33+
model: this.app.service('devices').Model,
34+
as: 'device'
3535
}]
3636
}
3737
});

src/services/users/users.class.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ exports.Users = class Users extends Service {
88
async remove(id, params) {
99
const user = await this.get(id);
1010
const ret = super.remove(id, params);
11-
if (user["role"] === "patient") {
12-
await this.app.service("patient").remove(user["patient.id"]);
11+
if (user['role'] === 'patient') {
12+
await this.app.service('patient').remove(user['patient.id']);
1313
}
14-
if (user["role"] === "doctor") {
15-
await this.app.service("doctor").remove(user["doctor.id"]);
14+
if (user['role'] === 'doctor') {
15+
await this.app.service('doctor').remove(user['doctor.id']);
1616
}
1717
return ret;
1818
}
@@ -39,14 +39,14 @@ exports.Users = class Users extends Service {
3939
...params,
4040
sequelize: {
4141
include: [{
42-
model: this.app.service("doctor").Model,
43-
as: "doctor"
42+
model: this.app.service('doctor').Model,
43+
as: 'doctor'
4444
}, {
45-
model: this.app.service("patient").Model,
46-
as: "patient",
45+
model: this.app.service('patient').Model,
46+
as: 'patient',
4747
include: [{
48-
model: this.app.service("devices").Model,
49-
as: "device"
48+
model: this.app.service('devices').Model,
49+
as: 'device'
5050
}]
5151
}]
5252
}

test/services/patient.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ describe('\'patient\' service', () => {
88
assert.ok(service, 'Registered the service');
99
});
1010

11-
describe("register new patient", () => {
11+
describe('register new patient', () => {
1212
const userInfo = {
13-
email: "example@patient.com",
14-
password: "secretpatient",
15-
role: "patient"
16-
}
13+
email: 'example@patient.com',
14+
password: 'secretpatient',
15+
role: 'patient'
16+
};
1717
before(async () => {
1818
try {
19-
await app.services("users").create(userInfo);
19+
await app.services('users').create(userInfo);
2020
} catch (error) {
21-
21+
// Do nothing, it just means the user already exists and can be tested
2222
}
2323
});
24-
it("user with role `patient` registered", async () => {
24+
it('user with role `patient` registered', async () => {
2525

26-
})
27-
})
26+
});
27+
});
2828
});

0 commit comments

Comments
 (0)