diff --git a/packages/api/Dockerfile b/packages/api/Dockerfile index 4f47adf0e1..6112922546 100644 --- a/packages/api/Dockerfile +++ b/packages/api/Dockerfile @@ -3,13 +3,13 @@ FROM node:18-alpine AS builder RUN corepack enable +RUN apk add --no-cache --virtual .gyp python3 py-setuptools make g++ + # Set the working directory in the container WORKDIR /app COPY . . -RUN apk add --no-cache --virtual .gyp python3 py-setuptools make g++ - # Install dependencies RUN yarn install @@ -23,10 +23,10 @@ FROM node:18-alpine WORKDIR /app # Copy the built files from the builder stage -COPY --from=builder /app . +COPY --from=builder /app/packages/api . # Expose the port the app runs on EXPOSE 8080:8080 # Define the command to run the app -CMD ["node", "packages/api/dist/server.js"] +CMD ["node", "dist/server.js"] diff --git a/packages/api/package.json b/packages/api/package.json index 7f126fe4f2..27a640ac94 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -2,8 +2,7 @@ "name": "api", "packageManager": "yarn@3.6.1", "dependencies": { - "@imtbl/config": "0.0.0", - "@imtbl/orderbook": "0.0.0", + "@imtbl/sdk": "1.47.8", "fastify": "^4.28.1" }, "devDependencies": { diff --git a/packages/api/src/server.ts b/packages/api/src/server.ts index 6ce039111f..839ec789f2 100644 --- a/packages/api/src/server.ts +++ b/packages/api/src/server.ts @@ -1,18 +1,17 @@ import fastify from 'fastify'; import 'dotenv/config'; -import { Orderbook } from '@imtbl/orderbook'; -import { Environment } from '@imtbl/config'; +import { orderbook, config } from '@imtbl/sdk'; const server = fastify(); -const orderbook = new Orderbook({ +const ob = new orderbook.Orderbook({ baseConfig: { - environment: process.env.IMMUTABLE_ENV as Environment || Environment.SANDBOX, + environment: process.env.IMMUTABLE_ENV as config.Environment || config.Environment.SANDBOX, }, }); const packages: { [key: string]: any } = { - orderbook, + orderbook: ob, }; // TODO: add validation @@ -22,8 +21,11 @@ const packages: { [key: string]: any } = { // TODO: newrelic // TODO: no deployment of alpha package on flux commit // TODO: env for production vs sandbox -server.post('/v1/ts-sdk/v1/:pkg/:method', async (request: any) => { +server.post('/v1/ts-sdk/v1/:pkg/:method', async (request: any, reply) => { const { pkg, method } = request.params; + if (Object.keys(packages).indexOf(pkg) === -1) { + return reply.code(400).send({ error: 'Invalid package' }); + } return await packages[pkg][method](request.body); }); diff --git a/yarn.lock b/yarn.lock index 80cf0e9f8f..0561340d5e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5113,6 +5113,73 @@ __metadata: languageName: unknown linkType: soft +"@imtbl/sdk@npm:1.47.8": + version: 1.47.8 + resolution: "@imtbl/sdk@npm:1.47.8" + dependencies: + "@0xsequence/abi": ^1.4.3 + "@0xsequence/core": ^1.4.3 + "@biom3/design-tokens": ^0.4.2 + "@biom3/react": ^0.25.0 + "@ethersproject/abi": ^5.7.0 + "@ethersproject/abstract-signer": ^5.7.0 + "@ethersproject/keccak256": ^5.7.0 + "@ethersproject/providers": ^5.7.2 + "@ethersproject/strings": ^5.7.0 + "@ethersproject/wallet": ^5.7.0 + "@imtbl/react-analytics": 0.2.1-alpha + "@jest/globals": ^29.5.0 + "@magic-ext/oidc": 4.3.1 + "@metamask/detect-provider": ^2.0.0 + "@opensea/seaport-js": 4.0.3 + "@rive-app/react-canvas-lite": ^4.9.0 + "@stdlib/number-float64-base-normalize": 0.0.8 + "@uniswap/router-sdk": ^1.4.0 + "@uniswap/sdk-core": ^3.0.1 + "@uniswap/v3-sdk": ^3.9.0 + "@walletconnect/ethereum-provider": ^2.11.1 + "@walletconnect/modal": ^2.6.2 + assert: ^2.0.0 + axios: ^1.6.5 + bn.js: ^5.2.1 + buffer: ^6.0.3 + crypto-browserify: ^3.12.0 + elliptic: ^6.5.4 + enc-utils: ^3.0.0 + ethereumjs-wallet: ^1.0.2 + ethers: ^5.7.2 + ethers-v6: "npm:ethers@6.11.1" + events: ^3.3.0 + global-const: ^0.1.2 + https-browserify: ^1.0.0 + i18next: ^23.7.6 + i18next-browser-languagedetector: ^7.2.0 + jwt-decode: ^3.1.2 + localforage: ^1.10.0 + lru-memorise: 0.3.0 + magic-sdk: ^21.2.0 + merkletreejs: ^0.3.11 + oidc-client-ts: 2.4.0 + os-browserify: ^0.3.0 + pako: ^2.1.0 + pg: ^8.11.5 + pino-pretty: ^11.2.2 + prisma: ^5.13.0 + react-i18next: ^13.5.0 + sns-validator: ^0.3.5 + stream-browserify: ^3.0.0 + stream-http: ^3.2.0 + url: ^0.11.0 + uuid: ^8.3.2 + dependenciesMeta: + pg: + optional: true + prisma: + optional: true + checksum: bc967dc2667df092249ee396b8263d6dde915dad764efb35238ac1b24217ceb47c8719fb4a331668818ee3c6c8683b4ae0bde2cd84fa23e1409a6dd4d8dd4dab + languageName: node + linkType: hard + "@imtbl/sdk@npm:latest": version: 1.46.5 resolution: "@imtbl/sdk@npm:1.46.5" @@ -15934,8 +16001,7 @@ __metadata: version: 0.0.0-use.local resolution: "api@workspace:packages/api" dependencies: - "@imtbl/config": 0.0.0 - "@imtbl/orderbook": 0.0.0 + "@imtbl/sdk": 1.47.8 "@nx-tools/container-metadata": ^6.0.2 "@nx-tools/nx-container": ^6.0.2 "@nx/devkit": ^19.6.1