Assume a template syntax where you can use {x}
, {{x}}
, and {{{x}}}
. How can we leverage regular expressions for this?
Example snippet:
{b} c {{d}} e {{{f}}} g
import { Context } from 'aws-lambda'; /* npm install @types/aws-lambda */ | |
export interface IMiddleware<E, R> { | |
process(event: E, context: Context, next: IHandler<E, R>): Promise<R>; | |
} | |
export interface IHandler<E, R> { | |
handle(event: E, context: Context): Promise<R>; | |
} | |
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; | |
export class ApiGatewayCorrelationContextMiddleware implements IMiddleware<APIGatewayProxyEvent, APIGatewayProxyResult> { | |
public async process(event: APIGatewayProxyEvent, next: Handler<APIGatewayProxyEvent, APIGatewayProxyResult>): Promise<APIGatewayProxyResult> { | |
return next(event); | |
} | |
} | |
class SomeMiddleware implements IMiddleware<APIGatewayProxyEvent, APIGatewayProxyResult> { | |
public async process(event: APIGatewayProxyEvent, next: EventHandler<APIGatewayProxyEvent, APIGatewayProxyResult>): Promise<APIGatewayProxyResult> { |
/* eslint-disable max-classes-per-file */ | |
/* | |
* An experiment about how we can structure this codebase | |
*/ | |
/* | |
* Request handling infrastructure | |
*/ |
// Using AWS Cognito via TypeScript | |
import { AdminCreateUserCommand, AdminDeleteUserCommand, CognitoIdentityProviderClient } from '@aws-sdk/client-cognito-identity-provider'; | |
const addresses = [ | |
// valid | |
'[email protected]', | |
'[email protected]', | |
'"name..name"@example.com', | |
'name@localhost', |
'use strict'; | |
import { createServer } from 'node:http'; | |
/* | |
* Usage: | |
* node server.js | |
* | |
* This will pick a random available port on your local machine. You can steer the port and host using environment variables: | |
* PORT=8080 HOST=localhost node server.js |