Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create folder structure #1

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
config
20 changes: 20 additions & 0 deletions DB/DB_Utils/codeSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Schema } from "mongoose";

export const codeSchema = new Schema(
{
code: {
type: String,
min: [6, "Code length must be 5 character"],
max: [6, "Code length must be 5 character"],
},
status: {
type: String,
enum: ["password", "confirm", "confirmChange", "unsubscribe"],
required: true,
},
createdAt: Date,
},
{
_id: false,
}
);
9 changes: 9 additions & 0 deletions DB/DB_Utils/imageSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Schema } from "mongoose";


export const imageSchema = new Schema({
secure_url: { type: String, required: true },
public_id: { type: String, required: true },
}, {
_id: false
})
11 changes: 11 additions & 0 deletions DB/dbConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import mongoose from "mongoose";

export const dbConnection = async () => {
return await mongoose.connect(process.env.DB_ATLAS).then(() => {
console.log("db connection successfully ........ ");
}).catch(() => {
console.log("db connection failed ********");
})
}

mongoose.set('strictQuery', true);
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import path from 'path'
import { fileURLToPath } from 'url'
import dotenv from 'dotenv'
//set directory dirname
const __dirname = path.dirname(fileURLToPath(import.meta.url))
dotenv.config({ path: path.join(__dirname, './config/.env') })
import express from 'express'
import initApp from './src/index.router.js'
const app = express()
// setup port and the baseUrl
const port = process.env.PORT || 5000
initApp(app ,express)
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Loading