@vsaas/loopback 12.1.1 → 12.2.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 +6 -0
- package/common/models/rate-limit-state.json +121 -0
- package/common/models/two-factor-challenge.json +112 -0
- package/common/models/two-factor-credential.json +117 -0
- package/common/models/two-factor-recovery-code.json +63 -0
- package/common/models/user.json +30 -0
- package/dist/_virtual/_rolldown/runtime.cjs +9 -2
- package/dist/common/models/access-token.d.cts +3 -0
- package/dist/common/models/acl.cjs +1 -3
- package/dist/common/models/acl.d.cts +1 -0
- package/dist/common/models/application.d.cts +3 -0
- package/dist/common/models/change.cjs +21 -18
- package/dist/common/models/change.d.cts +1 -0
- package/dist/common/models/checkpoint.d.cts +3 -0
- package/dist/common/models/email.d.cts +3 -0
- package/dist/common/models/key-value-model.d.cts +3 -0
- package/dist/common/models/rate-limit-state.cjs +7 -0
- package/dist/common/models/rate-limit-state.d.cts +3 -0
- package/dist/common/models/rate-limit-state2.cjs +109 -0
- package/dist/common/models/role-mapping.d.cts +3 -0
- package/dist/common/models/role.cjs +12 -8
- package/dist/common/models/role.d.cts +1 -0
- package/dist/common/models/scope.d.cts +3 -0
- package/dist/common/models/two-factor-challenge.cjs +7 -0
- package/dist/common/models/two-factor-challenge.d.cts +3 -0
- package/dist/common/models/two-factor-challenge2.cjs +108 -0
- package/dist/common/models/two-factor-credential.cjs +7 -0
- package/dist/common/models/two-factor-credential.d.cts +3 -0
- package/dist/common/models/two-factor-credential2.cjs +103 -0
- package/dist/common/models/two-factor-recovery-code.cjs +7 -0
- package/dist/common/models/two-factor-recovery-code.d.cts +3 -0
- package/dist/common/models/two-factor-recovery-code2.cjs +57 -0
- package/dist/common/models/user.cjs +261 -21
- package/dist/common/models/user.d.cts +3 -0
- package/dist/common/models/user2.cjs +30 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -0
- package/dist/lib/access-context.d.cts +33 -0
- package/dist/lib/application.d.cts +1 -0
- package/dist/lib/authentication-security-initializer.cjs +351 -0
- package/dist/lib/authentication-security-initializer.d.cts +4 -0
- package/dist/lib/builtin-models.cjs +12 -0
- package/dist/lib/builtin-models.d.cts +3 -0
- package/dist/lib/configure-shared-methods.cjs +7 -4
- package/dist/lib/configure-shared-methods.d.cts +3 -0
- package/dist/lib/connectors/base-connector.d.cts +6 -0
- package/dist/lib/connectors/mail-direct-transport.cjs +26 -23
- package/dist/lib/connectors/mail-direct-transport.d.cts +22 -0
- package/dist/lib/connectors/mail-stub-transport.d.cts +14 -0
- package/dist/lib/connectors/mail.d.cts +7 -0
- package/dist/lib/connectors/memory.d.cts +6 -0
- package/dist/lib/current-context.d.cts +3 -0
- package/dist/lib/globalize.d.cts +10 -0
- package/dist/lib/loopback.cjs +6 -0
- package/dist/lib/loopback.d.cts +1 -0
- package/dist/lib/model.d.cts +1 -0
- package/dist/lib/persisted-model.cjs +7 -12
- package/dist/lib/persisted-model.d.cts +1 -0
- package/dist/lib/rate-limit/algorithms/common.cjs +37 -0
- package/dist/lib/rate-limit/algorithms/failure-lockout.cjs +70 -0
- package/dist/lib/rate-limit/algorithms/fixed-window.cjs +61 -0
- package/dist/lib/rate-limit/algorithms/index.cjs +55 -0
- package/dist/lib/rate-limit/config.cjs +107 -0
- package/dist/lib/rate-limit/errors.cjs +58 -0
- package/dist/lib/rate-limit/index.cjs +15 -0
- package/dist/lib/rate-limit/index.d.cts +1 -0
- package/dist/lib/rate-limit/initializer.cjs +92 -0
- package/dist/lib/rate-limit/initializer.d.cts +4 -0
- package/dist/lib/rate-limit/limiter.cjs +368 -0
- package/dist/lib/rate-limit/registry.cjs +92 -0
- package/dist/lib/rate-limit/remote.cjs +180 -0
- package/dist/lib/rate-limit/remote.d.cts +6 -0
- package/dist/lib/rate-limit/stores/persisted-model.cjs +353 -0
- package/dist/lib/rate-limit/subject.cjs +127 -0
- package/dist/lib/rate-limit/types.cjs +1 -0
- package/dist/lib/rate-limit/types.d.cts +167 -0
- package/dist/lib/registry.d.cts +1 -0
- package/dist/lib/runtime.d.cts +10 -0
- package/dist/lib/server-app.d.cts +3 -0
- package/dist/lib/two-factor/config.cjs +199 -0
- package/dist/lib/two-factor/config.d.cts +55 -0
- package/dist/lib/two-factor/crypto.cjs +68 -0
- package/dist/lib/two-factor/crypto.d.cts +16 -0
- package/dist/lib/two-factor/errors.cjs +58 -0
- package/dist/lib/two-factor/errors.d.cts +18 -0
- package/dist/lib/two-factor/rate-limit.cjs +153 -0
- package/dist/lib/two-factor/rate-limit.d.cts +22 -0
- package/dist/lib/two-factor/recovery-codes.cjs +49 -0
- package/dist/lib/two-factor/recovery-codes.d.cts +16 -0
- package/dist/lib/two-factor/service.cjs +1108 -0
- package/dist/lib/two-factor/service.d.cts +78 -0
- package/dist/lib/two-factor/totp.cjs +50 -0
- package/dist/lib/two-factor/totp.d.cts +14 -0
- package/dist/lib/utils.d.cts +36 -0
- package/dist/package.cjs +46 -10
- package/dist/server/middleware/context.d.cts +3 -0
- package/dist/server/middleware/error-handler.d.cts +3 -0
- package/dist/server/middleware/favicon.d.cts +7 -0
- package/dist/server/middleware/rest.d.cts +6 -0
- package/dist/server/middleware/static.d.cts +3 -0
- package/dist/server/middleware/status.d.cts +19 -0
- package/dist/server/middleware/token.d.cts +3 -0
- package/dist/server/middleware/url-not-found.d.cts +13 -0
- package/docs/api-explorer-details.md +110 -0
- package/docs/application-guide.md +1110 -0
- package/docs/assets/explorer-api.png +0 -0
- package/docs/assets/explorer-endpoint.png +0 -0
- package/docs/assets/explorer-listing.png +0 -0
- package/docs/assets/explorer-req-res.png +0 -0
- package/docs/assets/lb-modules.png +0 -0
- package/docs/assets/loopback-architecture.png +0 -0
- package/docs/assets/loopback-concepts.png +0 -0
- package/docs/assets/loopback_ov.png +0 -0
- package/docs/rate-limiting.md +879 -0
- package/docs/two-factor-authentication.md +611 -0
- package/docs/two-factor-authenticator-loss-runbook.md +117 -0
- package/package.json +56 -20
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { NormalizedTwoFactorConfig } from "./config.cjs";
|
|
2
|
+
import { AuthenticationRateLimiter } from "./rate-limit.cjs";
|
|
3
|
+
//#region src/lib/two-factor/service.d.ts
|
|
4
|
+
declare class TwoFactorService {
|
|
5
|
+
private readonly User;
|
|
6
|
+
private readonly config;
|
|
7
|
+
private readonly rateLimiter;
|
|
8
|
+
private readonly app;
|
|
9
|
+
private readonly Credential;
|
|
10
|
+
private readonly Challenge;
|
|
11
|
+
private readonly RecoveryCode;
|
|
12
|
+
private readonly dummyPasswordUser;
|
|
13
|
+
constructor(User: any, config: NormalizedTwoFactorConfig | null, rateLimiter: AuthenticationRateLimiter | null, app: any);
|
|
14
|
+
login(credentials: any, include: any, options: any, callback?: (error?: any, token?: any) => void): Promise<any>;
|
|
15
|
+
verifyTwoFactor(verification: any, options?: any, callback?: (error?: any, token?: any) => void): Promise<any>;
|
|
16
|
+
beginEnrollment(userId: any, request: any, options: any, callback?: Function): Promise<{
|
|
17
|
+
enrollmentId: string;
|
|
18
|
+
secret: string;
|
|
19
|
+
keyUri: string;
|
|
20
|
+
expiresIn: number;
|
|
21
|
+
}>;
|
|
22
|
+
confirmEnrollment(userId: any, request: any, options: any, callback?: Function): Promise<{
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
recoveryCodes: string[];
|
|
25
|
+
}>;
|
|
26
|
+
regenerateRecoveryCodes(userId: any, request: any, options: any, callback?: Function): Promise<{
|
|
27
|
+
recoveryCodes: any;
|
|
28
|
+
}>;
|
|
29
|
+
disable(userId: any, request: any, options: any, callback?: Function): Promise<{
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
deletePrincipals(principalIds: ReadonlyArray<any>, callback?: Function): Promise<void>;
|
|
33
|
+
rotateEncryption(options?: any, callback?: Function): Promise<{
|
|
34
|
+
credentialsReencrypted: number;
|
|
35
|
+
challengesReencrypted: number;
|
|
36
|
+
conflicts: number;
|
|
37
|
+
remainingCredentials: number;
|
|
38
|
+
remainingChallenges: number;
|
|
39
|
+
}>;
|
|
40
|
+
private requireConfig;
|
|
41
|
+
private loginInternal;
|
|
42
|
+
private validateLoginQuery;
|
|
43
|
+
private canonicalIdentifier;
|
|
44
|
+
private consumePasswordFailures;
|
|
45
|
+
private resolveSource;
|
|
46
|
+
private hasPassword;
|
|
47
|
+
private issueAccessToken;
|
|
48
|
+
private buildTwoFactorTokenOptions;
|
|
49
|
+
private secretAad;
|
|
50
|
+
private challengeAad;
|
|
51
|
+
private principalBinding;
|
|
52
|
+
private assertPrincipalBinding;
|
|
53
|
+
private createChallenge;
|
|
54
|
+
private createInlineRecoveryOperation;
|
|
55
|
+
private verifyChallengeInternal;
|
|
56
|
+
private verifyCredentialFactor;
|
|
57
|
+
private reserveRecoveryCode;
|
|
58
|
+
private confirmRecoveryReservation;
|
|
59
|
+
private releaseRecoveryReservation;
|
|
60
|
+
private compensateChallengeFailure;
|
|
61
|
+
private beginEnrollmentInternal;
|
|
62
|
+
private confirmEnrollmentInternal;
|
|
63
|
+
private regenerateRecoveryCodesInternal;
|
|
64
|
+
private disableInternal;
|
|
65
|
+
private authenticatedUser;
|
|
66
|
+
private reauthenticateManagement;
|
|
67
|
+
private consumeManagementFailure;
|
|
68
|
+
private enabledCredential;
|
|
69
|
+
private persistRecoverySet;
|
|
70
|
+
private deletePrincipalsInternal;
|
|
71
|
+
private rotateEncryptionInternal;
|
|
72
|
+
private revokeSessions;
|
|
73
|
+
private revokeToken;
|
|
74
|
+
private reportCleanupError;
|
|
75
|
+
private audit;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { TwoFactorService };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
//#region src/lib/two-factor/totp.ts
|
|
4
|
+
function generateTotpSecret(bytes) {
|
|
5
|
+
return otplib.generateSecret({ length: bytes });
|
|
6
|
+
}
|
|
7
|
+
function generateTotpUri(secret, issuer, accountName, parameters) {
|
|
8
|
+
return otplib.generateURI({
|
|
9
|
+
issuer,
|
|
10
|
+
label: accountName,
|
|
11
|
+
secret,
|
|
12
|
+
algorithm: parameters.algorithm.toLowerCase(),
|
|
13
|
+
digits: parameters.digits,
|
|
14
|
+
period: parameters.period
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function verifyTotp(secret, token, parameters, maxClockSkewSteps, nowMs = Date.now()) {
|
|
18
|
+
if (typeof token !== "string" || !new RegExp(`^\\d{${parameters.digits}}$`).test(token)) return {
|
|
19
|
+
valid: false,
|
|
20
|
+
counter: -1
|
|
21
|
+
};
|
|
22
|
+
const result = otplib.verifySync({
|
|
23
|
+
secret,
|
|
24
|
+
token,
|
|
25
|
+
algorithm: parameters.algorithm.toLowerCase(),
|
|
26
|
+
digits: parameters.digits,
|
|
27
|
+
period: parameters.period,
|
|
28
|
+
epoch: Math.floor(nowMs / 1e3),
|
|
29
|
+
epochTolerance: maxClockSkewSteps * parameters.period
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
valid: result.valid === true,
|
|
33
|
+
counter: result.valid ? result.timeStep : -1
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var otplib;
|
|
37
|
+
var init_totp = require_runtime.__esmMin((() => {
|
|
38
|
+
otplib = require("otplib");
|
|
39
|
+
}));
|
|
40
|
+
//#endregion
|
|
41
|
+
init_totp();
|
|
42
|
+
exports.generateTotpSecret = generateTotpSecret;
|
|
43
|
+
exports.generateTotpUri = generateTotpUri;
|
|
44
|
+
Object.defineProperty(exports, "init_totp", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function() {
|
|
47
|
+
return init_totp;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
exports.verifyTotp = verifyTotp;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/lib/two-factor/totp.d.ts
|
|
2
|
+
interface TotpParameters {
|
|
3
|
+
algorithm: 'SHA1' | 'SHA256';
|
|
4
|
+
digits: 6 | 8;
|
|
5
|
+
period: number;
|
|
6
|
+
}
|
|
7
|
+
declare function generateTotpSecret(bytes: number): string;
|
|
8
|
+
declare function generateTotpUri(secret: string, issuer: string, accountName: string, parameters: TotpParameters): string;
|
|
9
|
+
declare function verifyTotp(secret: string, token: string, parameters: TotpParameters, maxClockSkewSteps: number, nowMs?: number): {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
counter: number;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { TotpParameters, generateTotpSecret, generateTotpUri, verifyTotp };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/lib/utils.d.ts
|
|
2
|
+
declare function createPromiseCallback(): any;
|
|
3
|
+
declare function asCallback(promise: any, cb: any): any;
|
|
4
|
+
declare function invokeWithCallback(fn: any, receiver: any, args: any): Promise<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Divide an async call with large array into multiple calls using smaller chunks
|
|
7
|
+
* @param {Array} largeArray - the large array to be chunked
|
|
8
|
+
* @param {Number} chunkSize - size of each chunks
|
|
9
|
+
* @param {Function} processFunction - the function to be called multiple times
|
|
10
|
+
* @param {Function} cb - the callback
|
|
11
|
+
*/
|
|
12
|
+
declare function uploadInChunks(largeArray: any, chunkSize: any, processFunction: any, cb: any): any;
|
|
13
|
+
/**
|
|
14
|
+
* Page async download calls
|
|
15
|
+
* @param {Object} filter - filter object used for the async call
|
|
16
|
+
* @param {Number} chunkSize - size of each chunks
|
|
17
|
+
* @param {Function} processFunction - the function to be called multiple times
|
|
18
|
+
* @param {Function} cb - the callback
|
|
19
|
+
*/
|
|
20
|
+
declare function downloadInChunks(filter: any, chunkSize: any, processFunction: any, cb: any): any;
|
|
21
|
+
/**
|
|
22
|
+
* Concat current results into previous results
|
|
23
|
+
* Assumption made here that the previous results and current results are homogeneous
|
|
24
|
+
* @param {Object|Array} previousResults
|
|
25
|
+
* @param {Object|Array} currentResults
|
|
26
|
+
*/
|
|
27
|
+
declare function concatResults(previousResults: any, currentResults: any): any;
|
|
28
|
+
declare const utils: {
|
|
29
|
+
asCallback: typeof asCallback;
|
|
30
|
+
concatResults: typeof concatResults;
|
|
31
|
+
createPromiseCallback: typeof createPromiseCallback;
|
|
32
|
+
downloadInChunks: typeof downloadInChunks;
|
|
33
|
+
invokeWithCallback: typeof invokeWithCallback;
|
|
34
|
+
uploadInChunks: typeof uploadInChunks;
|
|
35
|
+
};
|
|
36
|
+
export = utils;
|
package/dist/package.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
|
|
3
3
|
module.exports = {
|
|
4
4
|
"name": "@vsaas/loopback",
|
|
5
|
-
"version": "12.
|
|
5
|
+
"version": "12.2.1",
|
|
6
6
|
"description": "Fork of LoopBack 3 framework for building APIs and microservices in Node.js",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"StrongLoop",
|
|
@@ -38,21 +38,56 @@ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs"
|
|
|
38
38
|
"files": [
|
|
39
39
|
"dist",
|
|
40
40
|
"common/models",
|
|
41
|
+
"docs",
|
|
41
42
|
"templates",
|
|
42
43
|
"favicon.ico",
|
|
43
44
|
"README.md",
|
|
44
45
|
"LICENSE"
|
|
45
46
|
],
|
|
46
47
|
"main": "dist/index.cjs",
|
|
48
|
+
"types": "dist/index.d.cts",
|
|
47
49
|
"exports": {
|
|
48
|
-
".":
|
|
50
|
+
".": {
|
|
51
|
+
"types": "./dist/index.d.cts",
|
|
52
|
+
"require": "./dist/index.cjs",
|
|
53
|
+
"default": "./dist/index.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./rate-limit": {
|
|
56
|
+
"types": "./dist/lib/rate-limit/types.d.cts",
|
|
57
|
+
"require": "./dist/lib/rate-limit/types.cjs",
|
|
58
|
+
"default": "./dist/lib/rate-limit/types.cjs"
|
|
59
|
+
},
|
|
49
60
|
"./common/models/*.json": "./common/models/*.json",
|
|
50
|
-
"./common/models/*.js":
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"./
|
|
61
|
+
"./common/models/*.js": {
|
|
62
|
+
"types": "./dist/common/models/*.d.cts",
|
|
63
|
+
"require": "./dist/common/models/*.cjs",
|
|
64
|
+
"default": "./dist/common/models/*.cjs"
|
|
65
|
+
},
|
|
66
|
+
"./common/models/*": {
|
|
67
|
+
"types": "./dist/common/models/*.d.cts",
|
|
68
|
+
"require": "./dist/common/models/*.cjs",
|
|
69
|
+
"default": "./dist/common/models/*.cjs"
|
|
70
|
+
},
|
|
71
|
+
"./lib/*.js": {
|
|
72
|
+
"types": "./dist/lib/*.d.cts",
|
|
73
|
+
"require": "./dist/lib/*.cjs",
|
|
74
|
+
"default": "./dist/lib/*.cjs"
|
|
75
|
+
},
|
|
76
|
+
"./lib/*": {
|
|
77
|
+
"types": "./dist/lib/*.d.cts",
|
|
78
|
+
"require": "./dist/lib/*.cjs",
|
|
79
|
+
"default": "./dist/lib/*.cjs"
|
|
80
|
+
},
|
|
81
|
+
"./server/middleware/*.js": {
|
|
82
|
+
"types": "./dist/server/middleware/*.d.cts",
|
|
83
|
+
"require": "./dist/server/middleware/*.cjs",
|
|
84
|
+
"default": "./dist/server/middleware/*.cjs"
|
|
85
|
+
},
|
|
86
|
+
"./server/middleware/*": {
|
|
87
|
+
"types": "./dist/server/middleware/*.d.cts",
|
|
88
|
+
"require": "./dist/server/middleware/*.cjs",
|
|
89
|
+
"default": "./dist/server/middleware/*.cjs"
|
|
90
|
+
},
|
|
56
91
|
"./package.json": "./package.json"
|
|
57
92
|
},
|
|
58
93
|
"publishConfig": {
|
|
@@ -71,7 +106,7 @@ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs"
|
|
|
71
106
|
"typecheck": "tsc --noEmit"
|
|
72
107
|
},
|
|
73
108
|
"dependencies": {
|
|
74
|
-
"@aws-sdk/client-sesv2": "3.
|
|
109
|
+
"@aws-sdk/client-sesv2": "^3.1115.0",
|
|
75
110
|
"@vsaas/loopback-connector-remote": "workspace:^",
|
|
76
111
|
"@vsaas/loopback-datasource-juggler": "workspace:^",
|
|
77
112
|
"@vsaas/remoting": "workspace:^",
|
|
@@ -82,7 +117,8 @@ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs"
|
|
|
82
117
|
"express": "catalog:",
|
|
83
118
|
"isemail": "^3.2.0",
|
|
84
119
|
"loopback-filters": "^1.1.1",
|
|
85
|
-
"nodemailer": "^9.0.
|
|
120
|
+
"nodemailer": "^9.0.5",
|
|
121
|
+
"otplib": "catalog:",
|
|
86
122
|
"serve-favicon": "^2.5.1"
|
|
87
123
|
},
|
|
88
124
|
"devDependencies": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/server/middleware/status.d.ts
|
|
2
|
+
/*!
|
|
3
|
+
* Export the middleware.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Return [HTTP response](http://expressjs.com/4x/api.html#res.send) with basic application status information:
|
|
7
|
+
* date the application was started and uptime, in JSON format.
|
|
8
|
+
* For example:
|
|
9
|
+
* ```js
|
|
10
|
+
* {
|
|
11
|
+
* "started": "2014-06-05T00:26:49.750Z",
|
|
12
|
+
* "uptime": 9.394
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @header loopback.status()
|
|
17
|
+
*/
|
|
18
|
+
declare function status(): (req: any, res: any) => void;
|
|
19
|
+
export = status;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/server/middleware/url-not-found.d.ts
|
|
2
|
+
/*!
|
|
3
|
+
* Export the middleware.
|
|
4
|
+
* See discussion in Connect pull request #954 for more details
|
|
5
|
+
* https://github.com/senchalabs/connect/pull/954.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Convert any request not handled so far to a 404 error
|
|
9
|
+
* to be handled by error-handling middleware.
|
|
10
|
+
* @header loopback.urlNotFound()
|
|
11
|
+
*/
|
|
12
|
+
declare function urlNotFound(): (req: any, res: any, next: any) => void;
|
|
13
|
+
export = urlNotFound;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!-- NOTE: This file is not currently included into the docs. Need to (a) decide if this info is important and if so (b) decide where to put it.
|
|
2
|
+
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
# REST API specs
|
|
6
|
+
|
|
7
|
+
LoopBack API Explorer is built on top of the popular
|
|
8
|
+
[Swagger Framework](https://github.com/wordnik/swagger-core/wiki). There are two
|
|
9
|
+
components involved.
|
|
10
|
+
|
|
11
|
+
1. LoopBack builds up formal specifications of the REST APIs using the knowledge of
|
|
12
|
+
model definitions, JavaScript method declarations, and remote mappings. The
|
|
13
|
+
specifications are served over the following endpoints.
|
|
14
|
+
|
|
15
|
+
2. The wonderful Web UI is brought you by [Swagger UI](https://github.com/strongloop/swagger-ui).
|
|
16
|
+
Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically
|
|
17
|
+
generate beautiful documentation and sandbox from the REST API specifications.
|
|
18
|
+
|
|
19
|
+
## Resource Listing
|
|
20
|
+
|
|
21
|
+
The first part is a listing of the REST APIs.
|
|
22
|
+
|
|
23
|
+
- http://localhost:3000/swagger/resources
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
{
|
|
27
|
+
"swaggerVersion": "1.1",
|
|
28
|
+
"basePath": "http://localhost:3000",
|
|
29
|
+
"apis": [
|
|
30
|
+
{
|
|
31
|
+
"path": "/swagger/ammo"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "/swagger/customers"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "/swagger/inventory"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "/swagger/locations"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"path": "/swagger/weapons"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Resource Operations
|
|
50
|
+
|
|
51
|
+
The second part describes all operations of a given model.
|
|
52
|
+
|
|
53
|
+
- http://localhost:3000/swagger/locations
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
{
|
|
57
|
+
"swaggerVersion": "1.1",
|
|
58
|
+
"basePath": "http://localhost:3000",
|
|
59
|
+
"apis": [
|
|
60
|
+
{
|
|
61
|
+
"path": "/locations",
|
|
62
|
+
"operations": [
|
|
63
|
+
{
|
|
64
|
+
"httpMethod": "POST",
|
|
65
|
+
"nickname": "locations_create",
|
|
66
|
+
"responseClass": "object",
|
|
67
|
+
"parameters": [
|
|
68
|
+
{
|
|
69
|
+
"paramType": "body",
|
|
70
|
+
"name": "data",
|
|
71
|
+
"description": "Model instance data",
|
|
72
|
+
"dataType": "object",
|
|
73
|
+
"required": false,
|
|
74
|
+
"allowMultiple": false
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"errorResponses": [],
|
|
78
|
+
"summary": "Create a new instance of the model and persist it into the data source",
|
|
79
|
+
"notes": ""
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
...
|
|
84
|
+
{
|
|
85
|
+
"path": "/locations/{id}",
|
|
86
|
+
"operations": [
|
|
87
|
+
{
|
|
88
|
+
"httpMethod": "GET",
|
|
89
|
+
"nickname": "locations_findById",
|
|
90
|
+
"responseClass": "any",
|
|
91
|
+
"parameters": [
|
|
92
|
+
{
|
|
93
|
+
"paramType": "path",
|
|
94
|
+
"name": "id",
|
|
95
|
+
"description": "Model id",
|
|
96
|
+
"dataType": "any",
|
|
97
|
+
"required": true,
|
|
98
|
+
"allowMultiple": false
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"errorResponses": [],
|
|
102
|
+
"summary": "Find a model instance by id from the data source",
|
|
103
|
+
"notes": ""
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
...
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
```
|