Skip to content

Commit

Permalink
feat(discord): wip, add launch endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
shanedg committed May 28, 2024
1 parent 2d54509 commit ae2329c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions discord/lib/authenticated-api/handle-launch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// import { fetchWithOauth } from '../utils/get-fetch-with-oauth';

// Middleware handler that responds to new launch requests
// FIXME: ANNOTATE PARAMETER TYPES
// TODO: TEST
export const handleLaunch = async (fetch, guildId, request, response, next) => {
// TODO: 1. check request for required data

// TODO: 2. run command to launch instance

next(new Error('nope!'));
};
7 changes: 7 additions & 0 deletions discord/lib/authenticated-api/handle-launch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import test from 'ava';

// import { handleLaunch } from './handle-launch';

test('asdf', t => {
t.is(true, true);
});
4 changes: 4 additions & 0 deletions discord/lib/authenticated-api/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import express from 'express';
import { handleApiError } from './handle-api-error';
import { handleEndpointNotFound } from './handle-endpoint-not-found';
import { handleGetGuildMembership } from './handle-get-guild-membership';
import { handleLaunch } from './handle-launch';
import { requireAuthentication } from './require-authentication';
import { requireGuildMembership } from './require-guild-membership';

Expand Down Expand Up @@ -51,6 +52,9 @@ export class AuthenticatedAPIRouter {
// Deliver guild membership data to the frontend
authenticatedApiRouter.get('/authorized', handleGetGuildMembership);

// Accept requests to start up new servers
authenticatedApiRouter.post('/launch', handleLaunch.bind(null, this.configuration.fetch, this.configuration.guildId));

authenticatedApiRouter.use(handleApiError);

// Any unhandled requests at this point must be 404s
Expand Down

0 comments on commit ae2329c

Please sign in to comment.