Skip to content

Commit

Permalink
chore: remove unused dev routes (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensJourney authored Jul 29, 2024
1 parent 7b74e10 commit c9ad713
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 241 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-wasps-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@powersync/service-core': minor
'@powersync/service-types': minor
---

Removed unused development routes
3 changes: 1 addition & 2 deletions packages/service-core/src/routes/configure-fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as system from '../system/system-index.js';

import { ADMIN_ROUTES } from './endpoints/admin.js';
import { CHECKPOINT_ROUTES } from './endpoints/checkpointing.js';
import { DEV_ROUTES } from './endpoints/dev.js';
import { SYNC_RULES_ROUTES } from './endpoints/sync-rules.js';
import { SYNC_STREAM_ROUTES } from './endpoints/sync-stream.js';
import { createRequestQueueHook, CreateRequestQueueParams } from './hooks.js';
Expand Down Expand Up @@ -36,7 +35,7 @@ export type FastifyServerConfig = {

export const DEFAULT_ROUTE_OPTIONS = {
api: {
routes: [...ADMIN_ROUTES, ...CHECKPOINT_ROUTES, ...DEV_ROUTES, ...SYNC_RULES_ROUTES],
routes: [...ADMIN_ROUTES, ...CHECKPOINT_ROUTES, ...SYNC_RULES_ROUTES],
queueOptions: {
concurrency: 10,
max_queue_depth: 20
Expand Down
26 changes: 2 additions & 24 deletions packages/service-core/src/routes/endpoints/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,9 @@ import { internal_routes } from '@powersync/service-types';
import * as api from '../../api/api-index.js';
import * as util from '../../util/util-index.js';

import { routeDefinition } from '../router.js';
import { PersistedSyncRulesContent } from '../../storage/BucketStorage.js';
import { authApi } from '../auth.js';

const demoCredentials = routeDefinition({
path: '/api/admin/v1/demo-credentials',
method: router.HTTPMethod.POST,
authorize: authApi,
validator: schema.createTsCodecValidator(internal_routes.DemoCredentialsRequest, {
allowAdditional: true
}),
handler: async (payload) => {
const connection = payload.context.system.config.connection;
if (connection == null || !connection.demo_database) {
return internal_routes.DemoCredentialsResponse.encode({});
}

const uri = util.buildDemoPgUri(connection);
return internal_routes.DemoCredentialsResponse.encode({
credentials: {
postgres_uri: uri
}
});
}
});
import { routeDefinition } from '../router.js';

export const executeSql = routeDefinition({
path: '/api/admin/v1/execute-sql',
Expand Down Expand Up @@ -234,4 +212,4 @@ function mapColumnValue(value: SqliteValue) {
}
}

export const ADMIN_ROUTES = [demoCredentials, executeSql, diagnostics, getSchema, reprocess, validate];
export const ADMIN_ROUTES = [executeSql, diagnostics, getSchema, reprocess, validate];
199 changes: 0 additions & 199 deletions packages/service-core/src/routes/endpoints/dev.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './admin.js';
export * from './checkpointing.js';
export * from './dev.js';
export * from './socket-route.js';
export * from './sync-rules.js';
export * from './sync-stream.js';
15 changes: 0 additions & 15 deletions packages/types/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ export const ExecuteSqlResponse = t.object({
});
export type ExecuteSqlResponse = t.Encoded<typeof ExecuteSqlResponse>;

export const DemoCredentialsRequest = t.object({
connection_id: t.string.optional()
});
export type DemoCredentialsRequest = t.Encoded<typeof DemoCredentialsRequest>;

export const DemoCredentialsResponse = t.object({
/** If this instance has a demo database, this contains the credentials. */
credentials: t
.object({
postgres_uri: t.string
})
.optional()
});
export type DemoCredentialsResponse = t.Encoded<typeof DemoCredentialsResponse>;

export const DiagnosticsRequest = t.object({
sync_rules_content: t.boolean.optional()
});
Expand Down

0 comments on commit c9ad713

Please sign in to comment.