Giter Club home page Giter Club logo

ecrud's Introduction

eCRUD

A CRUD API for managing employee in-memory records

Endpoints

GET /employees

200 OK

[
    {
        "id": 1,
        "firstName": "John",
        "lastName": "Doe",
        "dateOfBirth": "1985-05-15",
        "email": "[email protected]",
        "isActive": true,
        "department": "Engineering",
        "role": "Software Developer"
    },
    {
        "id": 2,
        "firstName": "Jane",
        "lastName": "Smith",
        "dateOfBirth": "1990-09-22",
        "email": "[email protected]",
        "isActive": true,
        "department": "Marketing",
        "role": "Marketing Specialist"
    }
]

POST /employees

Request sample

{
    "firstName": "Jane",
    "lastName": "Smith",
    "dateOfBirth": "1990-09-22",
    "email": "[email protected]",
    "isActive": true,
    "department": "Marketing",
    "role": "Marketing Specialist"
}

200 OK

{
    "id": 1
}

400 Bad request

{
    "fields": ["email", "dateOfBirth"]
}

GET /employees/{id}

200 OK

{
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "dateOfBirth": "1985-05-15",
    "email": "[email protected]",
    "isActive": true,
    "department": "Engineering",
    "role": "Software Developer"
}

404 Not found

{
    "id": 1
}

PUT /employees/{id}

200 OK

{
    "message": "update success",
    "data": {
        "firstName": "Bruce",
        "lastName": "Wayne",
        "role": "CEO"
    }
}

DELETE /employees/{id}

200 OK

{
    "message": "delete success",
    "data": {
        "id": 1
    }
}

Development

โš ๏ธ This project requires at least Go 1.13. If you're running anything older, what are we doing here? ;) Just kidding, if you already have docker, you can follow the steps in Run via Docker section.

Build and run the server manually

  1. cd path/to/ecrud
  2. go build -o server cmd/server.go
  3. ./server
  4. Access via localhost:3000, ie. GET localhost:3000/employees/1

Run via docker

Start

  1. cd path/to/ecrud
  2. docker build -t arhyth:ecrud .
  3. docker run -p 80:3000 -d --name ecrud arhyth:ecrud
  4. Access via localhost, ie. GET localhost/employees/1

Cleanup

  1. docker stop ecrud
  2. docker rm ecrud
  3. docker rmi arhyth:ecrud

ecrud's People

Contributors

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