Skip to content

Commit

Permalink
Hangman game with backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ketan270 committed Apr 17, 2024
0 parents commit ad44585
Show file tree
Hide file tree
Showing 1,728 changed files with 275,612 additions and 0 deletions.
25 changes: 25 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express=require("express");
const app=express();
const port=5000;
const bodyParser = require('body-parser');
const mongoose=require("mongoose");
const usermodel= require("./models/usermodel");
mongoose.connect("mongodb://localhost:27017/mydatabase");
app.use(bodyParser.json());
app.use("/",(req,res)=>{
res.send("hello world");
})
app.post("/",(req,res)=>{
let name=req.name;
let email=req.email;
let password=req.password;
console.log(`${name } ${email } ${password}`);
usermodel.add({
name : name,
email:email,
password:password
})
})
app.listen(port,()=>{
console.log(`server is running at port ${port}`);
})
29 changes: 29 additions & 0 deletions backend/models/usermodel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const mongoose = require("mongoose");

const userSchema = mongoose.Schema({
name: {
type: String,
},
email: {
type: String,
required: true,
},
password: {
type: String,
required: true
}
});

const userModel = mongoose.model("User", userSchema);

const newUser = new userModel({
name: "Animesh sharma",
email: "[email protected]",
password: "123456678jj",
});

newUser.save()
.then(() => console.log("User added successfully"))
.catch(err => console.error("Error adding user:", err));

module.exports = userModel;
16 changes: 16 additions & 0 deletions backend/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions backend/node_modules/.bin/mime.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions backend/node_modules/.bin/nodemon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/node_modules/.bin/nodemon.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions backend/node_modules/.bin/nodemon.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions backend/node_modules/.bin/nodetouch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/node_modules/.bin/nodetouch.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions backend/node_modules/.bin/nodetouch.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions backend/node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/node_modules/.bin/nopt.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions backend/node_modules/.bin/nopt.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions backend/node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions backend/node_modules/.bin/semver.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions backend/node_modules/.bin/semver.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad44585

Please sign in to comment.