@unchainedshop/ticketing 4.8.4 → 5.0.0-alpha.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/lib/express.d.ts +2 -2
- package/lib/express.js +25 -14
- package/lib/fastify.d.ts +1 -1
- package/lib/fastify.js +40 -19
- package/lib/index.d.ts +6 -2
- package/package.json +9 -9
package/lib/express.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: (app:
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
declare const _default: (app: Express) => void;
|
|
3
3
|
export default _default;
|
package/lib/express.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import googleWalletHandler from "./mobile-tickets/google-handler-express.js";
|
|
4
|
-
import printTicketsHandler from "./pdf-tickets/print-handler-express.js";
|
|
1
|
+
import { createServerAdapter } from '@whatwg-node/server';
|
|
2
|
+
import { ticketingRoutes } from "./routes.js";
|
|
5
3
|
export default (app) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
for (const route of ticketingRoutes) {
|
|
5
|
+
const adapter = createServerAdapter(async (request, serverContext) => {
|
|
6
|
+
const context = {
|
|
7
|
+
...serverContext.unchainedContext,
|
|
8
|
+
params: serverContext.params || {},
|
|
9
|
+
};
|
|
10
|
+
return await route.handler(request, context);
|
|
11
|
+
});
|
|
12
|
+
const expressPath = route.path.replace(/\/\*$/, '/*');
|
|
13
|
+
app.use(expressPath, async (req, res) => {
|
|
14
|
+
try {
|
|
15
|
+
await adapter.handleNodeRequestAndResponse(req, res, {
|
|
16
|
+
unchainedContext: req.unchainedContext,
|
|
17
|
+
params: req.params,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
if (!res.headersSent) {
|
|
22
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
16
27
|
};
|
package/lib/fastify.d.ts
CHANGED
package/lib/fastify.js
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { createServerAdapter } from '@whatwg-node/server';
|
|
2
|
+
import { ticketingRoutes } from "./routes.js";
|
|
3
|
+
export default (fastify) => {
|
|
4
|
+
if (ticketingRoutes.length === 0)
|
|
5
|
+
return;
|
|
6
|
+
fastify.register((scope, opts, registered) => {
|
|
7
|
+
scope.removeAllContentTypeParsers();
|
|
8
|
+
scope.addContentTypeParser('*', function (request, payload, done) {
|
|
9
|
+
done(null);
|
|
10
|
+
});
|
|
11
|
+
for (const route of ticketingRoutes) {
|
|
12
|
+
const adapter = createServerAdapter(async (request, serverContext) => {
|
|
13
|
+
const context = {
|
|
14
|
+
...serverContext.unchainedContext,
|
|
15
|
+
params: serverContext.params || {},
|
|
16
|
+
};
|
|
17
|
+
return await route.handler(request, context);
|
|
18
|
+
});
|
|
19
|
+
const fastifyPath = route.path.replace(/\/\*$/, '/*');
|
|
20
|
+
scope.all(fastifyPath, async (req, reply) => {
|
|
21
|
+
try {
|
|
22
|
+
const response = await adapter.handleNodeRequestAndResponse(req.raw, reply.raw, {
|
|
23
|
+
unchainedContext: req.unchainedContext,
|
|
24
|
+
params: req.params,
|
|
25
|
+
});
|
|
26
|
+
response.headers.forEach((value, key) => {
|
|
27
|
+
reply.header(key, value);
|
|
28
|
+
});
|
|
29
|
+
reply.status(response.status);
|
|
30
|
+
reply.send(response.body || undefined);
|
|
31
|
+
return reply;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
if (!reply.sent) {
|
|
35
|
+
reply.status(500).send({ error: 'Internal Server Error' });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
registered();
|
|
20
41
|
});
|
|
21
42
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import type { UnchainedCore } from '@unchainedshop/core';
|
|
1
2
|
import { RendererTypes } from './template-registry.ts';
|
|
2
3
|
import ticketingModules, { type TicketingModule } from './module.ts';
|
|
3
|
-
import type { TicketingAPI } from './types.ts';
|
|
4
4
|
import ticketingServices, { type TicketingServices } from './services.ts';
|
|
5
|
-
export type
|
|
5
|
+
export type TicketingAPI = UnchainedCore & {
|
|
6
|
+
modules: TicketingModule;
|
|
7
|
+
services: TicketingServices;
|
|
8
|
+
};
|
|
9
|
+
export type { RendererTypes, TicketingModule, TicketingServices };
|
|
6
10
|
export { ticketingServices, ticketingModules };
|
|
7
11
|
export declare function setupPDFTickets({ renderOrderPDF }: {
|
|
8
12
|
renderOrderPDF: any;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/ticketing",
|
|
3
3
|
"description": "Event ticketing extension for the Unchained Engine with PDF and wallet pass support",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-alpha.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@unchainedshop/api": "^
|
|
38
|
-
"@unchainedshop/core": "^
|
|
39
|
-
"@unchainedshop/core-files": "^
|
|
40
|
-
"@unchainedshop/core-warehousing": "^
|
|
41
|
-
"@unchainedshop/core-worker": "^
|
|
42
|
-
"@unchainedshop/events": "^
|
|
43
|
-
"@unchainedshop/logger": "^
|
|
44
|
-
"@unchainedshop/mongodb": "^
|
|
37
|
+
"@unchainedshop/api": "^5.0.0-alpha.1",
|
|
38
|
+
"@unchainedshop/core": "^5.0.0-alpha.1",
|
|
39
|
+
"@unchainedshop/core-files": "^5.0.0-alpha.1",
|
|
40
|
+
"@unchainedshop/core-warehousing": "^5.0.0-alpha.1",
|
|
41
|
+
"@unchainedshop/core-worker": "^5.0.0-alpha.1",
|
|
42
|
+
"@unchainedshop/events": "^5.0.0-alpha.1",
|
|
43
|
+
"@unchainedshop/logger": "^5.0.0-alpha.1",
|
|
44
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@parse/node-apn": "^7.0.1",
|