Create Serverless Application with Express and Typescript — Part 1

Elias Junior
Dec 22, 2018 · 2 min read

The instructions and good patterns to start with this wonderful framework.

Hello everyone,today I’m going to show how to start a application with Serverless Framework, with some good practices and tips to facilitate with the process of the development of lambda functions on AWS.

I’m not going to show details about the stack we’re going to use, so you need to have a previous knowledge about all resources.

For this part we need to install the following items

First, we need to create a basic structure of project.

Basic Structure

Our package.json and tsconfig.json

So, to test our application, we will run npm start and the bin folder will be created with our javascript code.

Now, let’s create our first endpoint.

Route file with the routes of the our application.

// src/routes.tsimport * as Express from "express";const router = Express.Router();
router.get("/users", (request, response)=> { res.json({
status: "success",
data: [{
name: "User1"
});export default router;

Express structure configuration.

// src/app.tsimport * as Express from "express";
import * as bodyParser from "body-parser";
import routes from "./routes";class App { public app: Express.Application; constructor() { = Express();
private config() {;
}export default new App().app;

And the server file

import app from "./app";const PORT = 3000;app.listen(PORT, () => {
console.log(`Express server listening on port ${PORT}`);

Now, running our application again and making a request to the endpoint http://localhost:3000/users we see the users json returned.

It’s all for today, and next time we will add the Serverless Framework on application.

To acesss the second part of that article click here.

The project is on GitHub, click here to access.

Elias Junior

Written by

Full Stack Developer in 5 years, I like to study new technologies to keep me updated

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade