diff options
| -rw-r--r-- | package-lock.json | 20 | ||||
| -rw-r--r-- | package.json | 3 | ||||
| -rw-r--r-- | src/index.ts | 2 |
3 files changed, 24 insertions, 1 deletions
diff --git a/package-lock.json b/package-lock.json index a0a8cfa..e7bc110 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@tinyhttp/app": "2.0.16", + "@tinyhttp/cors": "2.0.0", "@tinyhttp/logger": "1.3.0", "pg": "8.7.3", "slam-types": "git://github.com/jantuomi/slam-types.git#441a72c", @@ -256,6 +257,17 @@ "node": ">=12.4.0" } }, + "node_modules/@tinyhttp/cors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.0.tgz", + "integrity": "sha512-IwQsPBnK+gRrhTsPA4FPOfbNzZZt8cVsOIMNFb6HzoScaiWcoLEogL0Bz/aBSm8KM13uieVXoVT6udMqhqUS2A==", + "dependencies": { + "es-vary": "^0.1.1" + }, + "engines": { + "node": ">=12.4 || 14.x || >=16" + } + }, "node_modules/@tinyhttp/encode-url": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.0.4.tgz", @@ -3565,6 +3577,14 @@ "resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.0.2.tgz", "integrity": "sha512-lyIdDzLILp6T2fymJn9zKBgXwlZMIUiqMUIEd4x/ZGFNvnNs/zeYDBQFdAygBtv4Bgl5Zpf6tN+e6fkj6TlMYQ==" }, + "@tinyhttp/cors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.0.tgz", + "integrity": "sha512-IwQsPBnK+gRrhTsPA4FPOfbNzZZt8cVsOIMNFb6HzoScaiWcoLEogL0Bz/aBSm8KM13uieVXoVT6udMqhqUS2A==", + "requires": { + "es-vary": "^0.1.1" + } + }, "@tinyhttp/encode-url": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.0.4.tgz", diff --git a/package.json b/package.json index d1e714e..9ccb9bc 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "license": "ISC", "dependencies": { "@tinyhttp/app": "2.0.16", + "@tinyhttp/cors": "2.0.0", "@tinyhttp/logger": "1.3.0", "pg": "8.7.3", "slam-types": "git://github.com/jantuomi/slam-types.git#441a72c", @@ -25,4 +26,4 @@ "eslint": "8.8.0", "nodemon": "2.0.15" } -}
\ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index c5cf39a..392827e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { App } from "@tinyhttp/app" import { logger } from "@tinyhttp/logger" +import { cors } from "@tinyhttp/cors" import pg from "pg" import { ExampleApi } from "slam-types" @@ -22,6 +23,7 @@ app .use(logger({ timestamp: { format: "YYYY-MM-DDTHH:mm:ssZ" }, })) + .use(cors()) .get(ExampleApi.ListRequest.path, async (_req, res) => { const examples: ExampleApi.Example[] = await client.query("SELECT * FROM examples").then(r => r.rows) const response: ExampleApi.ListResponse.Body = { |
