Skip to content

Commit

Permalink
Removing .js extensions, importing files w/ #src
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisischris committed Jun 17, 2024
1 parent c014ca1 commit 67bedb7
Show file tree
Hide file tree
Showing 33 changed files with 80 additions and 72 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"build:staging": "esbuild src/index.ts --bundle --platform=node --outdir=dist/lambda --external:@aws-sdk && cd dist/lambda && zip -r lambda.zip index.js > /dev/null && aws --profile equalify lambda update-function-code --function-name equalify-api-staging --zip-file \"fileb://lambda.zip\" > /dev/null && rm -rf dist/lambda/lambda.zip",
"build": "yarn build:staging && yarn build:prod"
},
"imports": {
"#src/*": "./src/*.ts"
},
"type": "module",
"dependencies": {},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Fastify from 'fastify';
import { addProperties, addReports, addResults, addScans, deleteProperties, deleteReports, getProperties, getReports, getResults, getScans, getUpdates, graphql, help, updateProperties, updateReports } from './routes/index.js';
import { addProperties, addReports, addResults, addScans, deleteProperties, deleteReports, getProperties, getReports, getResults, getScans, getUpdates, graphql, help, updateProperties, updateReports } from '#src/routes';
import { CognitoJwtVerifier } from 'aws-jwt-verify';
export const fastify = Fastify({ logger: true });
const cognitoJwtVerifier = CognitoJwtVerifier.create({
Expand Down
2 changes: 1 addition & 1 deletion src/cognito.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { postConfirmationConfirmSignUp, postConfirmationConfirmForgotPassword, customMessageSignUp, customMessageResendCode, customMessageForgotPassword, customMessageVerifyUserAttribute, customMessageUpdateUserAttribute } from 'cognito/index.js';
import { postConfirmationConfirmSignUp, postConfirmationConfirmForgotPassword, customMessageSignUp, customMessageResendCode, customMessageForgotPassword, customMessageVerifyUserAttribute, customMessageUpdateUserAttribute } from '#src/cognito/index';

export const cognito = async (event) => {
if (event.triggerSource === 'PostConfirmation_ConfirmSignUp') {
Expand Down
2 changes: 1 addition & 1 deletion src/cognito/customMessageForgotPassword.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatEmail } from "../utils";
import { formatEmail } from '#src/utils';

export const customMessageForgotPassword = async (event) => {
event.response.emailSubject = `Please reset your password`;
Expand Down
2 changes: 1 addition & 1 deletion src/cognito/customMessageResendCode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatEmail } from "../utils";
import { formatEmail } from '#src/utils';

export const customMessageResendCode = async (event) => {
event.response.emailSubject = `Equalify Verification Code`;
Expand Down
2 changes: 1 addition & 1 deletion src/cognito/customMessageSignUp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatEmail } from "../utils";
import { formatEmail } from '#src/utils';

export const customMessageSignUp = async (event) => {
event.response.emailSubject = `Equalify Verification Code`;
Expand Down
2 changes: 1 addition & 1 deletion src/cognito/customMessageUpdateUserAttribute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatEmail } from "../utils";
import { formatEmail } from '#src/utils';

export const customMessageUpdateUserAttribute = async (event) => {
event.response.emailSubject = `Please confirm your new email address`;
Expand Down
14 changes: 7 additions & 7 deletions src/cognito/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './postConfirmationConfirmSignUp.js'
export * from './postConfirmationConfirmForgotPassword.js'
export * from './customMessageSignUp.js'
export * from './customMessageVerifyUserAttribute.js'
export * from './customMessageUpdateUserAttribute.js'
export * from './customMessageResendCode.js'
export * from './customMessageForgotPassword.js'
export * from './postConfirmationConfirmSignUp'
export * from './postConfirmationConfirmForgotPassword'
export * from './customMessageSignUp'
export * from './customMessageVerifyUserAttribute'
export * from './customMessageUpdateUserAttribute'
export * from './customMessageResendCode'
export * from './customMessageForgotPassword'
2 changes: 1 addition & 1 deletion src/cognito/postConfirmationConfirmSignUp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pgClient } from "../utils/index.js";
import { pgClient } from '#src/utils';

export const postConfirmationConfirmSignUp = async (event) => {
const { sub, email, given_name, family_name } = event.request.userAttributes;
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import awsLambdaFastify from "@fastify/aws-lambda";
import { fastify } from "./app.js";
import { cognito } from './cognito.js';
import { scheduled } from './scheduled.js';
import awsLambdaFastify from '@fastify/aws-lambda';
import { fastify } from '#src/app';
import { cognito } from '#src/cognito';
import { scheduled } from '#src/scheduled';
const proxy = awsLambdaFastify(fastify);

export async function handler(event: any, context: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/addProperties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { formatId, pgClient, validateDiscovery, validateDiscoveryOptions, validateUrl } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { formatId, pgClient, validateDiscovery, validateDiscoveryOptions, validateUrl } from '#src/utils';

export const addProperties = async ({ request, reply }) => {
if (!request.body.propertyName) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/addReports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { formatId, pgClient } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { formatId, pgClient } from '#src/utils';

export const addReports = async ({ request, reply }) => {
if (!request.body.reportName) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/addResults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { formatId, pgClient } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { formatId, pgClient } from '#src/utils';

export const addResults = async ({ request, reply }) => {
await pgClient.connect();
Expand Down
4 changes: 2 additions & 2 deletions src/routes/addScans.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { pgClient, validateUrl } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { pgClient, validateUrl } from '#src/utils';

export const addScans = async ({ request, reply }) => {
if (!(request.body.propertyIds || request.body.urlIds)) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/deleteProperties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { pgClient, validateUuid } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { pgClient, validateUuid } from '#src/utils';

export const deleteProperties = async ({ request, reply }) => {
if (!request.query.propertyId) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/deleteReports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { pgClient, validateUuid } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { pgClient, validateUuid } from '#src/utils';

export const deleteReports = async ({ request, reply }) => {
if (!request.query.reportId) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/getProperties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const getProperties = async ({ request, reply }) => {
const response = (await graphqlQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/getReports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const getReports = async ({ request, reply }) => {
const response = (await graphqlQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/getResults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const getResults = async ({ request, reply }) => {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/routes/getScans.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const getScans = async ({ request, reply }) => {
const response = (await graphqlQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/getUpdates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const getUpdates = async ({ request, reply }) => {
const response = (await graphqlQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphqlQuery } from '../utils/index.js';
import { graphqlQuery } from '#src/utils';

export const graphql = async ({ request, reply }) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stripHtml } from 'string-strip-html';
import { openai } from '../utils/index.js';
import { openai } from '#src/utils';

export const help = async ({ request, reply }) => {
const { reportId, messageId, dequeURL, message: accessibilityIssueToFix, codeSnippet: originalCodeSnippet, sourceUrl, status } = request.body;
Expand Down
32 changes: 16 additions & 16 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export * from './addProperties.js'
export * from './addReports.js'
export * from './addResults.js'
export * from './addScans.js'
export * from './deleteProperties.js'
export * from './deleteReports.js'
export * from './getProperties.js'
export * from './getReports.js'
export * from './getResults.js'
export * from './getScans.js'
export * from './getUpdates.js'
export * from './graphql.js'
export * from './help.js'
export * from './updateProperties.js'
export * from './updateReports.js'
export * from './webhookMonitorUpdate.js'
export * from './addProperties'
export * from './addReports'
export * from './addResults'
export * from './addScans'
export * from './deleteProperties'
export * from './deleteReports'
export * from './getProperties'
export * from './getReports'
export * from './getResults'
export * from './getScans'
export * from './getUpdates'
export * from './graphql'
export * from './help'
export * from './updateProperties'
export * from './updateReports'
export * from './webhookMonitorUpdate'
4 changes: 2 additions & 2 deletions src/routes/updateProperties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { pgClient, validateDiscovery, validateDiscoveryOptions, validateUrl, validateUuid } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { pgClient, validateDiscovery, validateDiscoveryOptions, validateUrl, validateUuid } from '#src/utils';

export const updateProperties = async ({ request, reply }) => {
if (!validateUuid(request.body.propertyId)) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/updateReports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from '../app.js';
import { pgClient, validateUuid } from '../utils/index.js';
import { jwtClaims } from '#src/app';
import { pgClient, validateUuid } from '#src/utils';

export const updateReports = async ({ request, reply }) => {
if (!validateUuid(request.body.reportId)) {
Expand Down
2 changes: 1 addition & 1 deletion src/scheduled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { processScans, syncIpRanges } from './scheduled/index.js';
import { processScans, syncIpRanges } from '#src/scheduled/index';

export const scheduled = async (event) => {
if (event.internalPath.endsWith('/processScans')) {
Expand Down
4 changes: 2 additions & 2 deletions src/scheduled/processScans.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtClaims } from 'app';
import { pgClient } from 'utils';
import { jwtClaims } from '#src/app';
import { pgClient } from '#src/utils';

export const processScans = async () => {
// This route is called once every minute by Amazon EventBridge Scheduler
Expand Down
2 changes: 1 addition & 1 deletion src/scheduled/syncIpRanges.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EC2Client, DescribeSecurityGroupsCommand, RevokeSecurityGroupIngressCommand, AuthorizeSecurityGroupIngressCommand } from "@aws-sdk/client-ec2";
import { EC2Client, DescribeSecurityGroupsCommand, RevokeSecurityGroupIngressCommand, AuthorizeSecurityGroupIngressCommand } from '@aws-sdk/client-ec2';
const ec2Client = new EC2Client();

export const syncIpRanges = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/graphqlQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withPostGraphileContext, createPostGraphileSchema } from 'postgraphile'
import PgSimplifyInflectorPlugin from '@graphile-contrib/pg-simplify-inflector';
import ConnectionFilterPlugin from 'postgraphile-plugin-connection-filter';
import pg from 'pg';
import { jwtClaims } from '../app.js';
import { jwtClaims } from '#src/app';
const pool = new pg.Pool({ connectionString: process.env.DB_CONNECTION_URL });
const cache = createPostGraphileSchema(pool, 'public', {
appendPlugins: [PgSimplifyInflectorPlugin, ConnectionFilterPlugin],
Expand Down
16 changes: 8 additions & 8 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from './graphqlQuery.js'
export * from './pgClient.js'
export * from './openai.js'
export * from './validateUuid.js'
export * from './validateUrl.js'
export * from './validateDiscovery.js'
export * from './formatId.js'
export * from './formatEmail.js'
export * from './graphqlQuery'
export * from './pgClient'
export * from './openai'
export * from './validateUuid'
export * from './validateUrl'
export * from './validateDiscovery'
export * from './formatId'
export * from './formatEmail'
2 changes: 1 addition & 1 deletion src/utils/pgClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ServerlessClient from "serverless-postgres";
import ServerlessClient from 'serverless-postgres';

export const pgClient = new ServerlessClient({
user: process.env.DB_USER,
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"target": "ES2022",
"moduleResolution": "node",
"outDir": "./dist",
"baseUrl": "./src"
"baseUrl": "./src",
"paths": {
"#src/*": [
"./*"
]
}
}
}

0 comments on commit 67bedb7

Please sign in to comment.