@hemia/core 0.0.1 → 0.0.2
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/dist/hemia-core.esm.js +17 -0
- package/dist/hemia-core.js +17 -0
- package/dist/types/hemia-factory.d.ts +1 -0
- package/package.json +1 -1
package/dist/hemia-core.esm.js
CHANGED
|
@@ -261,6 +261,23 @@ class HemiaFactory {
|
|
|
261
261
|
const app = express();
|
|
262
262
|
app.use(express.json());
|
|
263
263
|
app.use(express.urlencoded({ extended: true }));
|
|
264
|
+
app.use((req, res, next) => {
|
|
265
|
+
const defaultHeaders = {
|
|
266
|
+
'Access-Control-Allow-Origin': req.headers.origin || '*',
|
|
267
|
+
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
268
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Api-Key, Language, X-No-Cookies, x-session',
|
|
269
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
270
|
+
'Access-Control-Expose-Headers': 'Authorization, X-Correlation-Id, X-Trace-Id, x-session',
|
|
271
|
+
};
|
|
272
|
+
const headers = { ...defaultHeaders, ...(options.corsHeaders || {}) };
|
|
273
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
274
|
+
res.header(key, value);
|
|
275
|
+
});
|
|
276
|
+
if (req.method === 'OPTIONS') {
|
|
277
|
+
return res.sendStatus(200);
|
|
278
|
+
}
|
|
279
|
+
next();
|
|
280
|
+
});
|
|
264
281
|
if (!container.isBound(Reflector)) {
|
|
265
282
|
container.bind(Reflector).toSelf().inSingletonScope();
|
|
266
283
|
}
|
package/dist/hemia-core.js
CHANGED
|
@@ -263,6 +263,23 @@ class HemiaFactory {
|
|
|
263
263
|
const app = express();
|
|
264
264
|
app.use(express.json());
|
|
265
265
|
app.use(express.urlencoded({ extended: true }));
|
|
266
|
+
app.use((req, res, next) => {
|
|
267
|
+
const defaultHeaders = {
|
|
268
|
+
'Access-Control-Allow-Origin': req.headers.origin || '*',
|
|
269
|
+
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
270
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Api-Key, Language, X-No-Cookies, x-session',
|
|
271
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
272
|
+
'Access-Control-Expose-Headers': 'Authorization, X-Correlation-Id, X-Trace-Id, x-session',
|
|
273
|
+
};
|
|
274
|
+
const headers = { ...defaultHeaders, ...(options.corsHeaders || {}) };
|
|
275
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
276
|
+
res.header(key, value);
|
|
277
|
+
});
|
|
278
|
+
if (req.method === 'OPTIONS') {
|
|
279
|
+
return res.sendStatus(200);
|
|
280
|
+
}
|
|
281
|
+
next();
|
|
282
|
+
});
|
|
266
283
|
if (!container.isBound(exports.Reflector)) {
|
|
267
284
|
container.bind(exports.Reflector).toSelf().inSingletonScope();
|
|
268
285
|
}
|