Skip to content

Commit

Permalink
Add version field to signed API
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed Dec 5, 2023
1 parent 1c3b93a commit 4ea7258
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ RUN addgroup -S deployed-api && \
USER deployed-api

COPY --chown=deployed-api:deployed-api --from=deployed-api /app/deployed-api .
ENTRYPOINT ["node", "dist/index.js"]
ENTRYPOINT ["node", "dist/src/index.js"]
4 changes: 4 additions & 0 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ An identifier of the deployment stage. This is used to distinguish between diffe
example `dev`, `staging` or `production`. The stage value can have 256 characters at maximum and can only include
lowercase alphanumeric characters and hyphens.

##### `version`

The version specified in the config must match the version of the Signed API at deployment time.

## API

The API provides the following endpoints:
Expand Down
3 changes: 2 additions & 1 deletion packages/api/config/signed-api.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
}
],
"allowedAirnodes": ["0xbF3137b0a7574563a23a8fC8badC6537F98197CC"],
"stage": "local"
"stage": "local",
"version": "0.1.0"
}
2 changes: 1 addition & 1 deletion packages/api/deployment/cloudformation-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"EntryPoint": [
"/bin/sh",
"-c",
"wget -O - <SIGNED_API_CONFIGURATION_URL> >> ./config/signed-api.json && node dist/index.js"
"wget -O - <SIGNED_API_CONFIGURATION_URL> >> ./config/signed-api.json && node dist/src/index.js"
],
"PortMappings": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "1.0.0",
"version": "0.1.0",
"engines": {
"node": "^18.18.2",
"pnpm": "^8.11.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { type LogFormat, logFormatOptions, logLevelOptions, type LogLevel } from
import { uniqBy } from 'lodash';
import { z } from 'zod';

import packageJson from '../package.json';

export const evmAddressSchema = z.string().regex(/^0x[\dA-Fa-f]{40}$/, 'Must be a valid EVM address');

export const evmIdSchema = z.string().regex(/^0x[\dA-Fa-f]{64}$/, 'Must be a valid EVM ID');
Expand Down Expand Up @@ -38,6 +40,7 @@ export const configSchema = z.strictObject({
stage: z
.string()
.regex(/^[\da-z-]{1,256}$/, 'Only lowercase letters, numbers and hyphens are allowed (max 256 characters)'),
version: z.string().refine((version) => version === packageJson.version, 'Invalid Signed API version'),
});

export type Config = z.infer<typeof configSchema>;
Expand Down

0 comments on commit 4ea7258

Please sign in to comment.