coupeeeez 0.0.1 → 0.0.3
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/package.json +3 -1
- package/stream-api/Message.d.ts +7 -0
- package/stream-api/Message.d.ts.map +1 -0
- package/stream-api/Message.js +1 -0
- package/stream-api/SSEInjected.d.ts +3 -0
- package/stream-api/SSEInjected.d.ts.map +1 -0
- package/stream-api/SSEInjected.js +2 -0
- package/stream-api/SSEServer.d.ts +9 -0
- package/stream-api/SSEServer.d.ts.map +1 -0
- package/stream-api/SSEServer.js +28 -0
- package/stream-api/SSEServers.d.ts +12 -0
- package/stream-api/SSEServers.d.ts.map +1 -0
- package/stream-api/SSEServers.js +27 -0
- package/stream-api/StreamApi.d.ts +2 -0
- package/stream-api/StreamApi.d.ts.map +1 -0
- package/stream-api/StreamApi.js +33 -0
- package/stream-api/app.d.ts +2 -0
- package/stream-api/app.d.ts.map +1 -0
- package/stream-api/app.js +9 -0
- package/stream-api/index.d.ts +2 -0
- package/stream-api/index.d.ts.map +1 -0
- package/stream-api/index.js +1 -0
- package/stream-api/node_modules/.package-lock.json +0 -9
- package/stream-api/package-lock.json +0 -10
- package/stream-api/package.json +0 -1
- package/stream-api/node_modules/commander/LICENSE +0 -22
- package/stream-api/node_modules/commander/Readme.md +0 -1159
- package/stream-api/node_modules/commander/esm.mjs +0 -16
- package/stream-api/node_modules/commander/index.js +0 -24
- package/stream-api/node_modules/commander/lib/argument.js +0 -150
- package/stream-api/node_modules/commander/lib/command.js +0 -2777
- package/stream-api/node_modules/commander/lib/error.js +0 -39
- package/stream-api/node_modules/commander/lib/help.js +0 -747
- package/stream-api/node_modules/commander/lib/option.js +0 -380
- package/stream-api/node_modules/commander/lib/suggestSimilar.js +0 -101
- package/stream-api/node_modules/commander/package-support.json +0 -16
- package/stream-api/node_modules/commander/package.json +0 -82
- package/stream-api/node_modules/commander/typings/esm.d.mts +0 -3
- package/stream-api/node_modules/commander/typings/index.d.ts +0 -1113
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coupeeeez",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Anthony REY",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"prepack": "tsc",
|
|
9
10
|
"start": "node app.ts",
|
|
10
11
|
"build": "npm run stream:build",
|
|
11
12
|
"test:component": "start-server-and-test stream-api:dev \"http://localhost:3005\" stream:dev:component \"http://localhost:3042\" cypress:open",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"node": "24.11.0"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
31
|
+
"commander": "^14.0.2",
|
|
30
32
|
"express": "^5.1.0"
|
|
31
33
|
},
|
|
32
34
|
"bin": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["Message.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSEInjected.d.ts","sourceRoot":"","sources":["SSEInjected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C,eAAO,MAAM,OAAO,YAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
import type { Message } from "./Message.ts";
|
|
3
|
+
export declare class SSEServer {
|
|
4
|
+
private res;
|
|
5
|
+
private constructor();
|
|
6
|
+
static start(res: Response): SSEServer;
|
|
7
|
+
send<T>(message: Message): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=SSEServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSEServer.d.ts","sourceRoot":"","sources":["SSEServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAE1C,qBAAa,SAAS;IAClB,OAAO,CAAC,GAAG,CAAW;IAEtB,OAAO;IAWP,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ;IAI1B,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO;CAe3B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class SSEServer {
|
|
2
|
+
res;
|
|
3
|
+
constructor(res) {
|
|
4
|
+
this.res = res;
|
|
5
|
+
const headers = {
|
|
6
|
+
'Content-Type': 'text/event-stream',
|
|
7
|
+
Connection: 'keep-alive',
|
|
8
|
+
'Cache-Control': 'no-cache'
|
|
9
|
+
};
|
|
10
|
+
this.res.writeHead(200, headers);
|
|
11
|
+
}
|
|
12
|
+
static start(res) {
|
|
13
|
+
return new SSEServer(res);
|
|
14
|
+
}
|
|
15
|
+
send(message) {
|
|
16
|
+
const { id, type = 'message', retry, data } = message;
|
|
17
|
+
if (id) {
|
|
18
|
+
this.res.write(`id: ${id}\n`);
|
|
19
|
+
}
|
|
20
|
+
if (type) {
|
|
21
|
+
this.res.write(`event: ${type}\n`);
|
|
22
|
+
}
|
|
23
|
+
if (retry) {
|
|
24
|
+
this.res.write(`retry: ${retry}\n`);
|
|
25
|
+
}
|
|
26
|
+
this.res.write(`data: ${JSON.stringify(data)}\n\n`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
import type { Message } from "./Message.ts";
|
|
3
|
+
export declare class SSEServers {
|
|
4
|
+
private readonly servers;
|
|
5
|
+
constructor();
|
|
6
|
+
open(clientId: string, res: Response): void;
|
|
7
|
+
delete(clientId: string): void;
|
|
8
|
+
deleteAll(): void;
|
|
9
|
+
broadcast(message: Message): void;
|
|
10
|
+
private unicast;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=SSEServers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSEServers.d.ts","sourceRoot":"","sources":["SSEServers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAE1C,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;;IAKjD,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ;IAIpC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAIvB,SAAS;IAKT,SAAS,CAAC,OAAO,EAAE,OAAO;IAM1B,OAAO,CAAC,OAAO;CAMlB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SSEServer } from "./SSEServer.js";
|
|
2
|
+
export class SSEServers {
|
|
3
|
+
servers;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.servers = new Map();
|
|
6
|
+
}
|
|
7
|
+
open(clientId, res) {
|
|
8
|
+
this.servers.set(clientId, SSEServer.start(res));
|
|
9
|
+
}
|
|
10
|
+
delete(clientId) {
|
|
11
|
+
this.servers.delete(clientId);
|
|
12
|
+
}
|
|
13
|
+
deleteAll() {
|
|
14
|
+
this.servers.clear();
|
|
15
|
+
}
|
|
16
|
+
broadcast(message) {
|
|
17
|
+
for (const [id] of this.servers) {
|
|
18
|
+
this.unicast(id, message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
unicast(clientId, message) {
|
|
22
|
+
if (!this.servers.has(clientId)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.servers.get(clientId).send(message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamApi.d.ts","sourceRoot":"","sources":["StreamApi.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,kDAkCrB,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { servers } from "./SSEInjected.js";
|
|
3
|
+
import short from "short-uuid";
|
|
4
|
+
export const streamApi = () => {
|
|
5
|
+
const router = express.Router();
|
|
6
|
+
router.use(express.json());
|
|
7
|
+
router.post('/api/movie', (req, res) => {
|
|
8
|
+
servers.broadcast({
|
|
9
|
+
type: 'movie.open',
|
|
10
|
+
data: {
|
|
11
|
+
name: req.body.name,
|
|
12
|
+
image: req.body.image,
|
|
13
|
+
year: req.body.year
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
res.send('Opened');
|
|
17
|
+
});
|
|
18
|
+
router.get('/api/movie', (req, res) => {
|
|
19
|
+
const uuid = short.generate();
|
|
20
|
+
servers.open(uuid, res);
|
|
21
|
+
req.on('close', () => {
|
|
22
|
+
servers.delete(uuid);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
router.delete('/api/movie', (req, res) => {
|
|
26
|
+
servers.broadcast({
|
|
27
|
+
type: 'movie.close',
|
|
28
|
+
data: { status: "closed" }
|
|
29
|
+
});
|
|
30
|
+
res.send('Closed');
|
|
31
|
+
});
|
|
32
|
+
return router;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { streamApi } from "./StreamApi.js";
|
|
3
|
+
const app = express();
|
|
4
|
+
const port = 3005;
|
|
5
|
+
app.get('/', (_, res) => res.send('Stream API'));
|
|
6
|
+
app.use(streamApi());
|
|
7
|
+
app.listen(port, () => {
|
|
8
|
+
console.log(`Example app listening on port ${port}`);
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { streamApi } from "./StreamApi.js";
|
|
@@ -202,15 +202,6 @@
|
|
|
202
202
|
"url": "https://github.com/sponsors/ljharb"
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
|
-
"node_modules/commander": {
|
|
206
|
-
"version": "14.0.2",
|
|
207
|
-
"resolved": "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz",
|
|
208
|
-
"integrity": "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==",
|
|
209
|
-
"license": "MIT",
|
|
210
|
-
"engines": {
|
|
211
|
-
"node": ">=20"
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
205
|
"node_modules/content-disposition": {
|
|
215
206
|
"version": "1.0.1",
|
|
216
207
|
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"commander": "^14.0.2",
|
|
13
12
|
"express": "^5.1.0",
|
|
14
13
|
"short-uuid": "^5.2.0"
|
|
15
14
|
},
|
|
@@ -216,15 +215,6 @@
|
|
|
216
215
|
"url": "https://github.com/sponsors/ljharb"
|
|
217
216
|
}
|
|
218
217
|
},
|
|
219
|
-
"node_modules/commander": {
|
|
220
|
-
"version": "14.0.2",
|
|
221
|
-
"resolved": "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz",
|
|
222
|
-
"integrity": "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==",
|
|
223
|
-
"license": "MIT",
|
|
224
|
-
"engines": {
|
|
225
|
-
"node": ">=20"
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
218
|
"node_modules/content-disposition": {
|
|
229
219
|
"version": "1.0.1",
|
|
230
220
|
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz",
|
package/stream-api/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|