@volcanicminds/backend 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/api/health/controller/health.js +1 -12
- package/dist/lib/api/health/controller/health.js.map +1 -1
- package/dist/lib/api/users/controller/user.js +4 -17
- package/dist/lib/api/users/controller/user.js.map +1 -1
- package/dist/package.json +1 -1
- package/lib/api/health/controller/health.ts +1 -1
- package/lib/api/users/controller/user.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -266,7 +266,7 @@ module.exports = {
|
|
|
266
266
|
// src/api/example/controller/demo.ts
|
|
267
267
|
import { FastifyReply, FastifyRequest } from '@volcanicminds/backend'
|
|
268
268
|
|
|
269
|
-
export
|
|
269
|
+
export function user(req: FastifyRequest, reply: FastifyReply) {
|
|
270
270
|
reply.send(req.user || {})
|
|
271
271
|
}
|
|
272
272
|
```
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.check = void 0;
|
|
13
4
|
function check(req, reply) {
|
|
14
|
-
|
|
15
|
-
reply.send({ ok: true });
|
|
16
|
-
});
|
|
5
|
+
reply.send({ ok: true });
|
|
17
6
|
}
|
|
18
7
|
exports.check = check;
|
|
19
8
|
//# sourceMappingURL=health.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../lib/api/health/controller/health.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../lib/api/health/controller/health.ts"],"names":[],"mappings":";;;AAEA,SAAgB,KAAK,CAAC,GAAmB,EAAE,KAAmB;IAC5D,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAC1B,CAAC;AAFD,sBAEC"}
|
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.isAdmin = exports.user = void 0;
|
|
13
4
|
function user(req, reply) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reply.send(user ? Object.assign(Object.assign({}, user), { roles: req.roles() }) : {});
|
|
17
|
-
});
|
|
5
|
+
const user = req.user;
|
|
6
|
+
reply.send(user ? Object.assign(Object.assign({}, user), { roles: req.roles() }) : {});
|
|
18
7
|
}
|
|
19
8
|
exports.user = user;
|
|
20
9
|
function isAdmin(req, reply) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
reply.send({ isAdmin: (user === null || user === void 0 ? void 0 : user.getId()) && req.hasRole(roles.admin) });
|
|
24
|
-
});
|
|
10
|
+
const user = req.user;
|
|
11
|
+
reply.send({ isAdmin: (user === null || user === void 0 ? void 0 : user.getId()) && req.hasRole(roles.admin) });
|
|
25
12
|
}
|
|
26
13
|
exports.isAdmin = isAdmin;
|
|
27
14
|
//# sourceMappingURL=user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../lib/api/users/controller/user.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../lib/api/users/controller/user.ts"],"names":[],"mappings":";;;AAGA,SAAgB,IAAI,CAAC,GAAmB,EAAE,KAAmB;IAC3D,MAAM,IAAI,GAAkC,GAAG,CAAC,IAAI,CAAA;IACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,iCAAM,IAAI,KAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAG,CAAC,CAAC,EAAE,CAAC,CAAA;AACzD,CAAC;AAHD,oBAGC;AAED,SAAgB,OAAO,CAAC,GAAmB,EAAE,KAAmB;IAC9D,MAAM,IAAI,GAAkC,GAAG,CAAC,IAAI,CAAA;IACpD,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAAE,KAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC;AAHD,0BAGC"}
|
package/dist/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FastifyReply, FastifyRequest } from 'fastify'
|
|
2
2
|
import { AuthenticatedUser } from '../../../../types/global'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export function user(req: FastifyRequest, reply: FastifyReply) {
|
|
5
5
|
const user: AuthenticatedUser | undefined = req.user
|
|
6
6
|
reply.send(user ? { ...user, roles: req.roles() } : {})
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export function isAdmin(req: FastifyRequest, reply: FastifyReply) {
|
|
10
10
|
const user: AuthenticatedUser | undefined = req.user
|
|
11
11
|
reply.send({ isAdmin: user?.getId() && req.hasRole(roles.admin) })
|
|
12
12
|
}
|