Skip to content

Instantly share code, notes, and snippets.

View lmas3009's full-sized avatar
🏡
Working from home

Aravind Kumar Vemula lmas3009

🏡
Working from home
View GitHub Profile
@lmas3009
lmas3009 / sample1.js
Created January 29, 2021 14:32
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
import express from 'express'
var app = express()
var port = process.env.PORT || 8080
app.get("/", function (req, res){
res.send( "Welcome to Tutorial of REST API using MongoDB, ExpressJS and NodeJS");
})
app.listen(port)
@lmas3009
lmas3009 / conbined_sample_code.js
Created January 29, 2021 15:11
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
import express from 'express'
import mongoose from "mongoose"
import Cors from 'cors'
var app = express()
var port = process.env.PORT || 8080
app.use(express.json())
app.use(Cors())
@lmas3009
lmas3009 / cars_schema.js
Created January 29, 2021 15:23
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
import mongoose from "mongoose"
const CarsSchema = mongoose.Schema({
Name: String,
Model: String,
Price: String,
meta: {
Fuel_Type: String,
Mileage: String,
Seating_Capacity: Number
@lmas3009
lmas3009 / cars_post.js
Created January 29, 2021 15:25
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
app.post("/Cars_add", function (req, res) {
const dbfeed = req.body
try {
Cars.create(dbfeed, (err, data) => {
if (err) {
res.status(500).send(err)
}
else {
res.status(201).send(data)
@lmas3009
lmas3009 / cars_get.js
Created January 29, 2021 15:25
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
app.get("/Cars", function (req, res) {
try {
Cars.find((err, data) => {
if (err) {
res.status(500).send(err)
}
else {
res.status(200).send(data)
}
@lmas3009
lmas3009 / combined_sample_get_post.js
Created January 29, 2021 15:29
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
import express from 'express'
import mongoose from "mongoose"
import Cors from 'cors'
import Cars from './Cars'
var app = express()
var port = process.env.PORT || 8080
app.use(express.json())
app.use(Cors())
@lmas3009
lmas3009 / package.json
Created January 29, 2021 15:38
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
{
"name": "rest_api",
"version": "1.0.0",
"description": "Rest API using MEN (MongoDB,ExpressJs and NodeJs)",
"main": "server.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js"
},
@lmas3009
lmas3009 / postman_data.json
Created January 29, 2021 16:00
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
[
{
"name": "Kia Sonet",
"Model": "Sonet",
"Price": "Rs. 6.79 - 13.19 Lakh",
"meta":{
"Fuel_Type": "Petrol / diesel",
"Mileage":"18.4 - 24.1 Kmpl",
"Seating_Capacity": 5
}
@lmas3009
lmas3009 / user_data_schema.js
Created January 31, 2021 14:01
A Simple MERN Full Stack Application
import mongoose from 'mongoose';
const UserDataSchema = mongoose.Schema({
Name: String,
FName: String,
Address: String,
PhonNo: String,
Email: String
})
@lmas3009
lmas3009 / get_post.js
Created January 31, 2021 14:03
A Simple MERN Full Stack Application
app.get("/details", function (req, res) {
UserDetails.find((err, data) => {
if (err) {
res.status(501).send(err)
}
else {
res.status(200).send(data)
}
})