@spinajs/intl-http 1.2.135
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 +11 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +43 -0
- package/lib/index.js.map +1 -0
- package/lib/intl-http.js +7 -0
- package/package.json +53 -0
package/README.md
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ServerMiddleware } from '@spinajs/http';
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
declare module '@spinajs/http' {
|
|
4
|
+
interface IActionLocalStoregeContext {
|
|
5
|
+
language: string;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class IntHttpMiddleware extends ServerMiddleware {
|
|
9
|
+
protected LangQueryParameter: string;
|
|
10
|
+
before(): (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
11
|
+
after(): (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
|
12
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IntHttpMiddleware = void 0;
|
|
13
|
+
const configuration_1 = require("@spinajs/configuration");
|
|
14
|
+
const di_1 = require("@spinajs/di");
|
|
15
|
+
const http_1 = require("@spinajs/http");
|
|
16
|
+
let IntHttpMiddleware = class IntHttpMiddleware extends http_1.ServerMiddleware {
|
|
17
|
+
before() {
|
|
18
|
+
return (req, _res, next) => {
|
|
19
|
+
if (req.query[this.LangQueryParameter]) {
|
|
20
|
+
req.storage.language = req.params[this.LangQueryParameter];
|
|
21
|
+
}
|
|
22
|
+
else if (req.cookies[this.LangQueryParameter]) {
|
|
23
|
+
req.storage.language = req.cookies[this.LangQueryParameter];
|
|
24
|
+
}
|
|
25
|
+
else if (req.headers[`x-${this.LangQueryParameter}`]) {
|
|
26
|
+
req.storage.language = req.headers[`x-${this.LangQueryParameter}`];
|
|
27
|
+
}
|
|
28
|
+
next();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
after() {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, configuration_1.Config)('intl.queryParameter'),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], IntHttpMiddleware.prototype, "LangQueryParameter", void 0);
|
|
39
|
+
IntHttpMiddleware = __decorate([
|
|
40
|
+
(0, di_1.Injectable)(http_1.ServerMiddleware)
|
|
41
|
+
], IntHttpMiddleware);
|
|
42
|
+
exports.IntHttpMiddleware = IntHttpMiddleware;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAgD;AAChD,oCAAyC;AACzC,wCAAsE;AAUtE,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,uBAAgB;IAI9C,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE;gBACtC,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;aAC5D;iBAAM,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE;gBAC/C,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;aAC7D;iBAAM,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,kBAAkB,EAAE,CAAC,EAAE;gBACtD,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,kBAAkB,EAAE,CAAW,CAAC;aAC9E;YAED,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IACM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAlBC;IADC,IAAA,sBAAM,EAAC,qBAAqB,CAAC;;6DACO;AAF1B,iBAAiB;IAD7B,IAAA,eAAU,EAAC,uBAAgB,CAAC;GAChB,iBAAiB,CAoB7B;AApBY,8CAAiB"}
|
package/lib/intl-http.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/intl-http",
|
|
3
|
+
"version": "1.2.135",
|
|
4
|
+
"description": "Internationalization support for http module",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && npm run compile",
|
|
9
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
10
|
+
"clean": "",
|
|
11
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
12
|
+
"coverage": "nyc npm run test",
|
|
13
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
|
+
"lint": "eslint -c .eslintrc.js --ext .ts src --fix",
|
|
17
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
18
|
+
"preversion": "npm run lint",
|
|
19
|
+
"version": "npm run format && git add -A src",
|
|
20
|
+
"postversion": "git push && git push --tags"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib/**/*"
|
|
24
|
+
],
|
|
25
|
+
"types": "lib",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"spinajs",
|
|
32
|
+
"int orm"
|
|
33
|
+
],
|
|
34
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@spinajs/configuration": "^1.2.127",
|
|
42
|
+
"@spinajs/di": "^1.2.127",
|
|
43
|
+
"@spinajs/exceptions": "^1.2.127",
|
|
44
|
+
"@spinajs/http": "^1.2.135",
|
|
45
|
+
"@spinajs/intl": "^1.2.135",
|
|
46
|
+
"@spinajs/log": "^1.2.127",
|
|
47
|
+
"@spinajs/reflection": "^1.2.127"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@spinajs/orm-sqlite": "^1.2.135"
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "8a7fde1b1fbada9c1b6fb65603ba1aadd5bb1126"
|
|
53
|
+
}
|