Giter VIP home page Giter VIP logo

my_first_api's Introduction

my_first_API

Coding my first, very basic, RESTful API, using the Express.js and Joi frameworks, to simply handle get, put, delete and post requests to a very simple JSON database.

To use, the following packages and frameworks must be installed, ideally in this order:

  • node.js
  • express.js
  • JOI
  • Insomnia (reccomended, to test the API with various types of request)

Installation and dependencies (Windows):

  1. Once node is installed, create a new folder to work in. Navigate to this folder via the command line, and run: npm init --yes.
  2. Next, run: npm i express
  3. Next, run: npm i joi
  4. Next, navigate to your new folder in whichever application you prefer: I prefer VSCode.
  5. Create a new file (I named mine index.js)
  6. Copy and paste in the code
  7. Install Insomnia and use this programme to test the API. An alternative would be Bootstrap, and the 'curl' command also works from the command line, in windows.

This API borrows heavily from the coding project detailed in the tutorial found at https://www.youtube.com/watch?v=pKd0Rpw7O48 . However, it is slightly different because some functions used in the video have since been changed in recent updates, notably the validate() function. I also added liberal use of comments for my own notes and learning purposes.

The function of this API is as a learning resource primarily. It can handle basic requests to modify and view a JSON database. It follows the REST conventions and Pascal naming conventions.

Skills used (Javascript):

  • the Joi package
  • Node.js and the Express.js API framework
  • extensive use of arrow functions and functional programming in general, but no use of OOP
  • diverse use of if/else logic and syntax
  • object destructuring notation, for code readability
  • error handling and very very limited edge case testing (because it's such a simple API)

Ideas for further projects: Since this is such a simple API it could be used in a huge variety of projects, since it simply posts to a JSON database. One idea would be using it for updating and managing a stock information database for the inventory of a small business, as the inventory of a shop is unlikely to need a more advanced database (e.g. a relational one) since almost no data/trend analysis is needed.

I will also progress to working with the Mongo.DB package to handle more extensive database management.

=

my_first_api's People

Contributors

archiegoodman2 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.