How to create a structured Typescript & Serverless project

Oscar de la Hera Gomez
Two flowers that represent Typescript & Serverless. Beneath them sits the text "Project Structure."

A guide for structuring Typescript & Serverless projects. Open source GitHub repository available.

The following guide walks you through how we structure Typescript & Serverless projects at delasign. These processes are used in our Open Source Typescript & Serverless project that is available in the link below.

Folder Structure

A screenshot of VSCode with the folder structure that we suggest you follow. This folder structure is detailed below.

We recommend fitting everything into four key folders: Functions, Modules, Types & Utils.

Functions

We recommend placing all your Serverless functions here and follow the sample code provided below.

For more information on the ideology behind structuring functions this way and using standardized responses please consult the tutorials below.

Modules

In order to reduce the complexity of your code and with the interest of making your code as reusable as possible, we suggest splitting your functionality into modules.

An example of two modules can be found below, the first being how to get an email and uses an identifier as suggested in our structured Typescript and Serverless article; to log the process and progress.

This module uses environment variables and calls a separate module, found below, which is used across the project to gather S3 objects.

Both of these are examples of reusable modules that can be used to simplify your code and create processes that can be thoughtfully logged to learn when issues arise.

Types

We recommend using this folder to store all the Typescript Types used by your system.

We recommend using sub-folders that speak to the system that you are using and that thoughtfully split up Types into logical groups.

Utils

We recommend using this folder to store all functionality that is not considered a module but which is required by the whole system.

Currently, our Open Source project holds the logs, responses and errors. Additional uses that could be contemplated include:

  • Storing constants
  • Common functionality like if an object exists or an email is valid

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.

delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details