This is a simple implementation of a RESTful API using Node.js for managing user-related operations. The API allows you to perform CRUD operations on user data, including user creation, retrieval, update, and deletion.
Built this api server using the core nodejs modules. This helped me understand the basics of nodejs functionalities and the many core nodejs modules, It helped me gain better knowledge of the javascript language and its beauty of callback functions. I learnt how express.js works and how much easy it has made to create servers🫡.
- used
httpmodule for creating server. - used
urlmodule for parsing the request url. - used
string_decodermodule for receiving client data. - used
cryptomodule for password hashing. - used
fsmodule for storing data in the file system.
git clone https://github.com/mnazneen20/user-api.git
The server will run on http://localhost:4000
POST request at /user
request body json (username should be unique)
Status: 201
{
"firstname":"John",
"lastname": "Doe",
"password": "pass123",
"username":"john22"
}
response:
{
"message": "New User Created"
}
GET request at /user?username=john22
response:
Status 200
{
"message": "User found",
"user": {
"firstname": "John",
"lastname": "Doe",
"username": "john22"
}
}
PUT request at /user?username=john22
request body json
{
"firstname":"John Anthony"
}
response:
Status: 200
{
"message": "User updated"
}
DELETE request at /user?username=john22
response:
Status: 200
{
"message": "User Deleted"
}