diff --git a/apps/api/package.json b/apps/api/package.json index 01a83880..788a01e7 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -21,6 +21,7 @@ "license": "ISC", "dependencies": { "@fastify/cookie": "^8.3.0", + "@fastify/cors": "^8.3.0", "@fastify/type-provider-typebox": "^3.1.0", "@fastify/under-pressure": "^8.2.0", "@fastify/websocket": "^7.2.0", @@ -39,8 +40,8 @@ "openpgp": "^5.5.0", "ref-napi": "^3.0.3", "rxjs": "^7.8.0", - "tsconfig-paths": "^4.1.2", - "ts-node": "^10.9.1" + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.1.2" }, "devDependencies": { "@superlight-labs/eslint-config": "*", diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index b91f355c..1feedb53 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -5,6 +5,7 @@ import config from '@lib/config'; import logger from '@superlight-labs/logger'; import { registerRoutes } from './routes/register-routes'; +import cors from '@fastify/cors'; import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'; import { PrismaClient } from '@superlight-labs/database'; import fastify from 'fastify'; @@ -29,6 +30,10 @@ export const createServer = async (client: PrismaClient) => { server.register(fastifyCookie, { secret: config.cookieSecret, }); + server.register(cors, { + origin: '*', + methods: ['GET', 'PUT', 'POST'], + }); server.register(underPressure, { maxHeapUsedBytes: 500 * 1000000, @@ -47,7 +52,11 @@ export const createServer = async (client: PrismaClient) => { registerRoutes(server); - server.all('*', (request, reply) => { + server.get('*', (request, reply) => { + reply.status(404).send({ error: 'Route does not exist' }); + }); + + server.post('*', (request, reply) => { reply.status(404).send({ error: 'Route does not exist' }); }); diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock index 2c431485..a71349f6 100644 --- a/apps/mobile/ios/Podfile.lock +++ b/apps/mobile/ios/Podfile.lock @@ -738,4 +738,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 2123bfe5ed3b5442a6d71ef2172de1bdfe243f18 -COCOAPODS: 1.12.0 +COCOAPODS: 1.12.1 diff --git a/docker-compose.yml b/docker-compose.yml index d9d9d667..1054446c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,11 @@ version: "3.8" services: api: - build: - context: . - dockerfile: ./apps/api/Dockerfile + image: superlight/superlight-api:latest + # In case you want to build locally, replace "image:"" with this + # build: + # context: . + # dockerfile: ./apps/api/Dockerfile ports: - ${API_PORT}:${API_PORT} environment: diff --git a/yarn.lock b/yarn.lock index f7d4e01b..12404141 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2158,6 +2158,14 @@ cookie "^0.5.0" fastify-plugin "^4.0.0" +"@fastify/cors@^8.3.0": + version "8.3.0" + resolved "https://registry.yarnpkg.com/@fastify/cors/-/cors-8.3.0.tgz#f03d745731b770793a1a15344da7220ca0d19619" + integrity sha512-oj9xkka2Tg0MrwuKhsSUumcAkfp2YCnKxmFEusi01pjk1YrdDsuSYTHXEelWNW+ilSy/ApZq0c2SvhKrLX0H1g== + dependencies: + fastify-plugin "^4.0.0" + mnemonist "0.39.5" + "@fastify/deepmerge@^1.0.0": version "1.3.0" resolved "https://registry.yarnpkg.com/@fastify/deepmerge/-/deepmerge-1.3.0.tgz#8116858108f0c7d9fd460d05a7d637a13fe3239a" @@ -9356,6 +9364,13 @@ mkdirp@^1.0.3, mkdirp@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mnemonist@0.39.5: + version "0.39.5" + resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.39.5.tgz#5850d9b30d1b2bc57cc8787e5caa40f6c3420477" + integrity sha512-FPUtkhtJ0efmEFGpU14x7jGbTB+s18LrzRL2KgoWz9YvcY3cPomz8tih01GbHwnGk/OmkOKfqd/RAQoc8Lm7DQ== + dependencies: + obliterator "^2.0.1" + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -9725,6 +9740,11 @@ object.values@^1.1.6: define-properties "^1.1.4" es-abstract "^1.20.4" +obliterator@^2.0.1: + version "2.0.4" + resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816" + integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ== + on-exit-leak-free@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-1.0.0.tgz#4a2accb382278a266848bb1a21439e5fc3cd9881"