Skip to content

Commit 81b37e7

Browse files
committed
update
1 parent a7b4f2b commit 81b37e7

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ COPY package*.json ./
77
COPY . .
88

99
# DEVELOPMENT - Enable Volume in docker-compose.yml
10-
#ENV NODE_ENV development
11-
#RUN npm install
12-
#CMD ["npx", "nodemon", "npm", "start"]
10+
ENV NODE_ENV development
11+
RUN npm install
12+
CMD ["npx", "nodemon", "npm", "start"]
1313

1414
# PRODUCTION
15-
ENV NODE_ENV production
16-
RUN npm install --production
17-
RUN adduser --disabled-password myuser
18-
USER myuser
19-
CMD ["npm", "start"]
15+
#ENV NODE_ENV production
16+
#RUN npm install --production
17+
#RUN adduser --disabled-password myuser
18+
#USER myuser
19+
#CMD ["npm", "start"]

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
dockerfile: Dockerfile
88
env_file: .env
99
restart: on-failure
10-
# volumes:
11-
# - ./:/service
10+
volumes:
11+
- ./:/service
1212
ports:
1313
- "443:443"
1414
- "80:80"

src/controller/StartupCommand.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {ServiceProxy} from "../model/ServiceProxy.js";
1818
import {ServiceMediator} from "../view/ServiceMediator.js";
1919
import {Service} from "../view/components/Service.js";
2020
import {MySQL} from "../model/connections/MySQL.js";
21-
import {User} from "../model/data/User.js";
22-
import {Role} from "../model/data/Role.js";
21+
import {UserData} from "../model/data/UserData.js";
22+
import {RoleData} from "../model/data/RoleData.js";
2323

2424
export class StartupCommand extends SimpleCommand {
2525

@@ -53,7 +53,7 @@ export class StartupCommand extends SimpleCommand {
5353
mySQL.tryConnecting()
5454
.then(() => {
5555
this.facade.registerCommand(ApplicationFacade.SERVICE, () => new ServiceCommand());
56-
this.facade.registerProxy(new ServiceProxy(mySQL, new User(), new Role()));
56+
this.facade.registerProxy(new ServiceProxy(mySQL, new UserData(), new RoleData()));
5757
this.facade.registerMediator(new ServiceMediator(new Service(options)));
5858
});
5959
}

src/model/ServiceProxy.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ export class ServiceProxy extends Proxy {
1212

1313
static get NAME() { return "ServiceProxy" };
1414

15-
constructor(mySQL, user, role) {
15+
constructor(mySQL, userData, roleData) {
1616
super(ServiceProxy.NAME, null);
1717
this.mySQL = mySQL;
18-
this.user = user;
19-
this.role = role;
18+
this.userData = userData;
19+
this.roleData = roleData;
2020
}
2121

2222
async findAllUsers() {
2323
const connection = await this.mySQL.getConnection();
2424
try {
25-
return await this.user.findAllUsers(connection);
25+
return await this.userData.findAllUsers(connection);
2626
} catch (error) {
2727
throw error;
2828
} finally {
@@ -33,7 +33,7 @@ export class ServiceProxy extends Proxy {
3333
async findUserById(id) {
3434
const connection = await this.mySQL.getConnection();
3535
try {
36-
return await this.user.findUserById(connection, id);
36+
return await this.userData.findUserById(connection, id);
3737
} catch(error) {
3838
throw error;
3939
} finally {
@@ -45,9 +45,9 @@ export class ServiceProxy extends Proxy {
4545
const connection = await this.mySQL.getConnection();
4646
try {
4747
await this.mySQL.beginTransaction(connection);
48-
const result = await this.user.add(connection, user);
48+
const result = await this.userData.add(connection, user);
4949
if (user.roles && user.roles.length > 0)
50-
await this.role.updateRolesById(connection, result.body.id, user.roles);
50+
await this.roleData.updateRolesById(connection, result.body.id, user.roles);
5151
await this.mySQL.commit(connection);
5252
return result;
5353
} catch(error) {
@@ -62,11 +62,11 @@ export class ServiceProxy extends Proxy {
6262
const connection = await this.mySQL.getConnection();
6363
try {
6464
await this.mySQL.beginTransaction(connection);
65-
const result = await this.user.update(connection, user);
65+
const result = await this.userData.update(connection, user);
6666
if (user.roles) {
67-
await this.role.deleteRolesById(connection, user.id);
67+
await this.roleData.deleteRolesById(connection, user.id);
6868
if (user.roles.length > 0)
69-
await this.role.updateRolesById(connection, user.id, user.roles)
69+
await this.roleData.updateRolesById(connection, user.id, user.roles)
7070
}
7171
await this.mySQL.commit(connection);
7272
result.body = user;
@@ -82,7 +82,7 @@ export class ServiceProxy extends Proxy {
8282
async deleteById(id) {
8383
const connection = await this.mySQL.getConnection();
8484
try {
85-
return await this.user.deleteById(connection, id);
85+
return await this.userData.deleteById(connection, id);
8686
} catch(error) {
8787
throw error;
8888
} finally {
@@ -93,7 +93,7 @@ export class ServiceProxy extends Proxy {
9393
async findAllDepartments() {
9494
const connection = await this.mySQL.getConnection();
9595
try {
96-
return await this.user.findAllDepartments(connection);
96+
return await this.userData.findAllDepartments(connection);
9797
} catch(error) {
9898
throw error;
9999
} finally {
@@ -104,7 +104,7 @@ export class ServiceProxy extends Proxy {
104104
async findAllRoles() {
105105
const connection = await this.mySQL.getConnection();
106106
try {
107-
return await this.role.findAllRoles(connection);
107+
return await this.roleData.findAllRoles(connection);
108108
} catch(error) {
109109
throw error;
110110
} finally {
@@ -115,7 +115,7 @@ export class ServiceProxy extends Proxy {
115115
async findRolesById(id) {
116116
const connection = await this.mySQL.getConnection();
117117
try {
118-
return await this.role.findRolesById(connection, id);
118+
return await this.roleData.findRolesById(connection, id);
119119
} catch(error) {
120120
throw error;
121121
} finally {
@@ -127,8 +127,8 @@ export class ServiceProxy extends Proxy {
127127
const connection = await this.mySQL.getConnection();
128128
try {
129129
await this.mySQL.beginTransaction(connection);
130-
await this.role.deleteRolesById(connection, id);
131-
const payload = await this.role.updateRolesById(connection, id, roles);
130+
await this.roleData.deleteRolesById(connection, id);
131+
const payload = await this.roleData.updateRolesById(connection, id, roles);
132132
await this.mySQL.commit(connection);
133133
return payload;
134134
} catch (error) {

src/model/data/Role.js renamed to src/model/data/RoleData.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//
2-
// Role.js
2+
// RoleData.js
33
// PureMVC JS Demo - EmployeeAdmin Microservice
44
//
55
// Copyright(c) 2023 Saad Shams <[email protected]>
66
// Your reuse is governed by the Creative Commons Attribution 3.0 License
77
//
88

9-
export class Role {
9+
export class RoleData {
1010

1111
constructor() {}
1212

src/model/data/User.js renamed to src/model/data/UserData.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//
2-
// User.js
2+
// UserData.js
33
// PureMVC JS Demo - EmployeeAdmin Microservice
44
//
55
// Copyright(c) 2023 Saad Shams <[email protected]>
66
// Your reuse is governed by the Creative Commons Attribution 3.0 License
77
//
88

9-
export class User {
9+
export class UserData {
1010

1111
constructor() {}
1212

0 commit comments

Comments
 (0)