Skip to content

Updates: Schemas, Naming, Tx Override, Packages #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Engine is an open-source, backend HTTP server that provides a production-ready i

## Get Engine

### Cloud-host

[Get Engine hosted and managed by thirdweb](https://thirdweb.com/dashboard/engine?requestCloudHosted).

### Self-host

Host Engine on your own instructure for free. [View self-host instructions](https://portal.thirdweb.com/engine/self-host).
Expand All @@ -48,10 +52,6 @@ Other deployment options:

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/fcEVay)

### Cloud-host

[Get Engine hosted and managed by thirdweb](https://thirdweb.com/dashboard/engine?requestCloudHosted).

## Contributing

We welcome contributions! See [How to contribute](./contributing.md).
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/access-tokens/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { env } from "../../../../utils/env";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
import { AccessTokenSchema } from "./getAll";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
label: Type.Optional(Type.String()),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Composite([
AccessTokenSchema,
Type.Object({
Expand All @@ -26,8 +26,8 @@ const ReplySchema = Type.Object({

export async function createAccessToken(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/access-tokens/create",
Expand All @@ -36,10 +36,10 @@ export async function createAccessToken(fastify: FastifyInstance) {
description: "Create a new access token",
tags: ["Access Tokens"],
operationId: "create",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/auth/access-tokens/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export const AccessTokenSchema = Type.Object({
label: Type.Union([Type.String(), Type.Null()]),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Array(AccessTokenSchema),
});

export async function getAllAccessTokens(fastify: FastifyInstance) {
fastify.route<{
Reply: Static<typeof ReplySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "GET",
url: "/auth/access-tokens/get-all",
Expand All @@ -30,7 +30,7 @@ export async function getAllAccessTokens(fastify: FastifyInstance) {
operationId: "getAll",
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/access-tokens/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { revokeToken } from "../../../../db/tokens/revokeToken";
import { accessTokenCache } from "../../../../utils/cache/accessToken";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
id: Type.String(),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
success: Type.Boolean(),
}),
});

export async function revokeAccessToken(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/access-tokens/revoke",
Expand All @@ -27,10 +27,10 @@ export async function revokeAccessToken(fastify: FastifyInstance) {
description: "Revoke an access token",
tags: ["Access Tokens"],
operationId: "revoke",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/access-tokens/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { updateToken } from "../../../../db/tokens/updateToken";
import { accessTokenCache } from "../../../../utils/cache/accessToken";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
id: Type.String(),
label: Type.Optional(Type.String()),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
success: Type.Boolean(),
}),
});

export async function updateAccessToken(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/access-tokens/update",
Expand All @@ -28,10 +28,10 @@ export async function updateAccessToken(fastify: FastifyInstance) {
description: "Update an access token",
tags: ["Access Tokens"],
operationId: "update",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/keypair/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "../../../schemas/keypairs";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
publicKey: Type.String({
description:
"The public key of your keypair beginning with '-----BEGIN PUBLIC KEY-----'.",
Expand All @@ -21,16 +21,16 @@ const BodySchema = Type.Object({
label: Type.Optional(Type.String()),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
keypair: KeypairSchema,
}),
});

export async function addKeypair(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/keypair/add",
Expand All @@ -39,10 +39,10 @@ export async function addKeypair(fastify: FastifyInstance) {
description: "Add the public key for a keypair",
tags: ["Keypair"],
operationId: "add",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/auth/keypair/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { listKeypairs } from "../../../../db/keypair/list";
import { KeypairSchema, toKeypairSchema } from "../../../schemas/keypairs";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Array(KeypairSchema),
});

export async function listPublicKeys(fastify: FastifyInstance) {
fastify.route<{
Reply: Static<typeof ReplySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "GET",
url: "/auth/keypair/get-all",
Expand All @@ -22,7 +22,7 @@ export async function listPublicKeys(fastify: FastifyInstance) {
operationId: "list",
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/keypair/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { deleteKeypair } from "../../../../db/keypair/delete";
import { keypairCache } from "../../../../utils/cache/keypair";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
hash: Type.String(),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
success: Type.Boolean(),
}),
});

export async function removePublicKey(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/keypair/remove",
Expand All @@ -27,10 +27,10 @@ export async function removePublicKey(fastify: FastifyInstance) {
description: "Remove the public key for a keypair",
tags: ["Keypair"],
operationId: "remove",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/auth/permissions/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StatusCodes } from "http-status-codes";
import { prisma } from "../../../../db/client";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Array(
Type.Object({
walletAddress: Type.String(),
Expand All @@ -16,7 +16,7 @@ const ReplySchema = Type.Object({

export async function getAllPermissions(fastify: FastifyInstance) {
fastify.route<{
Reply: Static<typeof ReplySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "GET",
url: "/auth/permissions/get-all",
Expand All @@ -27,7 +27,7 @@ export async function getAllPermissions(fastify: FastifyInstance) {
operationId: "getAll",
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
16 changes: 8 additions & 8 deletions src/server/routes/auth/permissions/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import { Static, Type } from "@sinclair/typebox";
import { FastifyInstance } from "fastify";
import { StatusCodes } from "http-status-codes";
import { updatePermissions } from "../../../../db/permissions/updatePermissions";
import { PermissionsSchema } from "../../../schemas/auth";
import { permissionsSchema } from "../../../schemas/auth";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
walletAddress: Type.String(),
permissions: PermissionsSchema,
permissions: permissionsSchema,
label: Type.Optional(Type.String()),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
success: Type.Boolean(),
}),
});

export async function grantPermissions(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/permissions/grant",
Expand All @@ -29,10 +29,10 @@ export async function grantPermissions(fastify: FastifyInstance) {
description: "Grant permissions to a user",
tags: ["Permissions"],
operationId: "grant",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/routes/auth/permissions/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import { StatusCodes } from "http-status-codes";
import { deletePermissions } from "../../../../db/permissions/deletePermissions";
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";

const BodySchema = Type.Object({
const requestBodySchema = Type.Object({
walletAddress: Type.String(),
});

const ReplySchema = Type.Object({
const responseBodySchema = Type.Object({
result: Type.Object({
success: Type.Boolean(),
}),
});

export async function revokePermissions(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof BodySchema>;
Reply: Static<typeof ReplySchema>;
Body: Static<typeof requestBodySchema>;
Reply: Static<typeof responseBodySchema>;
}>({
method: "POST",
url: "/auth/permissions/revoke",
Expand All @@ -26,10 +26,10 @@ export async function revokePermissions(fastify: FastifyInstance) {
description: "Revoke a user's permissions",
tags: ["Permissions"],
operationId: "revoke",
body: BodySchema,
body: requestBodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: ReplySchema,
[StatusCodes.OK]: responseBodySchema,
},
},
handler: async (req, res) => {
Expand Down
Loading
Loading