Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Elmer Bulthuis committed May 6, 2024
1 parent b914c56 commit ce5cf9f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/npm/reverse/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ async function main() {
// create and configure server

const server = new api.Server();
// register the reverse operation
server.registerReverseOperation(async (incomingRequest) => {
// get the text we want to reverse
const originalText = await incomingRequest.value();

// reverse the text
const reversedText = reverse(originalText);

// return the reversed text to the client
return {
status: 200,
contentType: "text/plain",
value: () => reversedText,
};
});

// serve a static file
// serve a static file (will be generic middleware in the future)
server.registerMiddleware(async (request, next) => {
if (request.method === "GET") {
switch (request.path) {
Expand Down Expand Up @@ -74,8 +79,7 @@ async function main() {
return response;
});

// read the port to listen to from the environment or use the default

// get port to listen to from the environment or use the default
const port = Number(process.env.PORT ?? 8080);

console.info(`Starting server...`);
Expand Down

0 comments on commit ce5cf9f

Please sign in to comment.