Giter Site home page Giter Site logo

express-typescript-app's Introduction

Express Typescript App

This application accompanies the blog post, Your First Node Express App with Typescript.

Setup

To set up the application, first clone the repo. Then, install the dependencies by running yarn:

yarn

Starting the Server

To start the server, run:

yarn run start

The server should now be running on port 3000.

Making Requests

The server only has a few endpoints:

  • GET /—Returns "hello world"
  • POST /users—Adds a username/password pair to an in-memory user store
  • POST /login—Validates a username/password agains the in-memory user store

The GET endpoint can be viewed simply by navigating to http://localhost:3000. You should see "Hello world".

You can use curl to send requests to the two POST endpoints. Here are some examples:

Register user

To create a new user with username foo and password bar:

curl -d "username=foo&password=bar" -X POST http://localhost:3000/users
# User created

To see the response of a malformed user registration request:

curl -d "username=foo&password= " -X POST http://localhost:3000/users
# Bad username or password

Log in

To log in with our previously-created user foo:

curl -d "username=foo&password=bar" -X POST http://localhost:3000/login
# Success

To see the response of a failed login request:

curl -d "username=foo&password=wrong" -X POST http://localhost:3000/users
# Login failed

express-typescript-app's People

Contributors

nas5w avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.