├── src ├── app.js ├── constants.js ├── db │ └── index.js └── index.js ├── public └── temp │ └── .gitkeep ├── Readme.md ├── .prettierignore ├── .env.example ├── .prettierrc ├── package.json └── .gitignore /src/app.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/temp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | The professional project of backend project -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | export const DB_NAME = "videotube" -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | /node_modules 3 | /dist 4 | 5 | *.env 6 | .env 7 | .env.* -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | PORT=8000 2 | MONGO_URI=mongodb+srv://:@youtube-database.dxq12cx.mongodb.net -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": false, 3 | "bracketSpacing": true, 4 | "tabWidth": 2, 5 | "trailingComma": "es5", 6 | "semi": true 7 | } -------------------------------------------------------------------------------- /src/db/index.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | import { DB_NAME } from "../constants.js"; 3 | 4 | const connectDB = async () => { 5 | try { 6 | const connectionInstance = await mongoose.connect( 7 | `${process.env.MONGODB_URI}/${DB_NAME}` 8 | ); 9 | console.log( 10 | `\n MongoDB connected !! DB HOST: ${connectionInstance.connection.host}` 11 | ); 12 | } catch (error) { 13 | console.log("MONGODB connection error ", error); 14 | process.exit(1); 15 | } 16 | }; 17 | 18 | export default connectDB; 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chai-aur-backend", 3 | "version": "1.0.0", 4 | "description": "a backend project at chai aur code channel - youtube", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "nodemon -r dotenv/config --experimental-json-modules src/index.js" 9 | }, 10 | "keywords": [ 11 | "javascript", 12 | "backend" 13 | ], 14 | "author": "Vishal Parmar", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "nodemon": "^3.1.0", 18 | "prettier": "^3.2.5" 19 | }, 20 | "dependencies": { 21 | "dotenv": "^16.4.5", 22 | "express": "^4.18.3", 23 | "mongoose": "^8.2.1" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // require('dotenv').config({path: './env'}) 2 | import dotenv from "dotenv"; 3 | import connectDB from "./db/index.js"; 4 | 5 | dotenv.config({ 6 | path: "./env", 7 | }); 8 | 9 | connectDB(); 10 | 11 | // import express from "express"; 12 | 13 | // const app = express(); 14 | // const PORT = process.env.PORT; 15 | 16 | // (async () => { 17 | // try { 18 | // await mongoose.connect(`${process.env.MONGODB_URI}/${DB_NAME}`); 19 | // app.on("error", (error) => { 20 | // console.log("ERROR: ", error); 21 | // throw error; 22 | // }); 23 | 24 | // app.listen(PORT, () => { 25 | // console.log("App is listening on ", PORT); 26 | // }); 27 | // } catch (error) { 28 | // console.error("ERROR: ", error); 29 | // throw err; 30 | // } 31 | // })(); 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | .env.production 76 | 77 | # parcel-bundler cache (https://parceljs.org/) 78 | .cache 79 | .parcel-cache 80 | 81 | # Next.js build output 82 | .next 83 | out 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | 110 | # Stores VSCode versions used for testing VSCode extensions 111 | .vscode-test 112 | 113 | # yarn v2 114 | .yarn/cache 115 | .yarn/unplugged 116 | .yarn/build-state.yml 117 | .yarn/install-state.gz 118 | .pnp.* 119 | 120 | # End of https://mrkandreev.name/snippets/gitignore-generator/#Node --------------------------------------------------------------------------------