@anmol0493/fullstack-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/backend-express/.env.example +2 -0
- package/backend-express/index.js +2 -0
- package/backend-express/package-lock.json +1939 -0
- package/backend-express/package.json +25 -0
- package/backend-express/src/config/db.js +20 -0
- package/backend-express/src/controller/auth.js +71 -0
- package/backend-express/src/middleware/auth.js +36 -0
- package/backend-express/src/middleware/validator.js +16 -0
- package/backend-express/src/models/user.js +26 -0
- package/backend-express/src/routes/auth.js +25 -0
- package/backend-express/src/server.js +28 -0
- package/backend-express/src/utils/constants.js +14 -0
- package/backend-express/src/utils/helper.js +30 -0
- package/backend-express/src/utils/schema/auth.js +34 -0
- package/backend-nestjs/.env.example +3 -0
- package/backend-nestjs/.prettierrc +4 -0
- package/backend-nestjs/README.md +99 -0
- package/backend-nestjs/eslint.config.mjs +35 -0
- package/backend-nestjs/nest-cli.json +8 -0
- package/backend-nestjs/package.json +99 -0
- package/backend-nestjs/pnpm-lock.yaml +7848 -0
- package/backend-nestjs/src/app.controller.ts +12 -0
- package/backend-nestjs/src/app.module.ts +13 -0
- package/backend-nestjs/src/app.service.ts +8 -0
- package/backend-nestjs/src/common/decorators/user.decorator.ts +8 -0
- package/backend-nestjs/src/common/dtos/common.dto.ts +87 -0
- package/backend-nestjs/src/common/enum/index.ts +0 -0
- package/backend-nestjs/src/common/exceptions/custom.exception.ts +28 -0
- package/backend-nestjs/src/common/filters/http-exception.filter.ts +46 -0
- package/backend-nestjs/src/common/guard/permission.guard.ts +18 -0
- package/backend-nestjs/src/common/middleware/auth.middleware.ts +20 -0
- package/backend-nestjs/src/common/pipes/validation.pipe.ts +61 -0
- package/backend-nestjs/src/common/utils/constants.ts +36 -0
- package/backend-nestjs/src/common/utils/helper.ts +43 -0
- package/backend-nestjs/src/core/core.module.ts +8 -0
- package/backend-nestjs/src/core/jwt/jwt.module.ts +10 -0
- package/backend-nestjs/src/core/jwt/jwt.service.ts +45 -0
- package/backend-nestjs/src/core/prisma/prisma.module.ts +9 -0
- package/backend-nestjs/src/core/prisma/prisma.service.ts +17 -0
- package/backend-nestjs/src/core/prisma/schema.prisma +27 -0
- package/backend-nestjs/src/main.ts +26 -0
- package/backend-nestjs/src/module/auth/auth.controller.ts +30 -0
- package/backend-nestjs/src/module/auth/auth.module.ts +10 -0
- package/backend-nestjs/src/module/auth/auth.service.ts +83 -0
- package/backend-nestjs/src/module/auth/dto/index.ts +28 -0
- package/backend-nestjs/src/module/index.module.ts +17 -0
- package/backend-nestjs/src/scripts/migrate.js +40 -0
- package/backend-nestjs/tsconfig.build.json +4 -0
- package/backend-nestjs/tsconfig.json +22 -0
- package/frontend/.env.example +1 -0
- package/frontend/README.md +54 -0
- package/frontend/eslint.config.js +28 -0
- package/frontend/index.html +13 -0
- package/frontend/package-lock.json +3813 -0
- package/frontend/package.json +43 -0
- package/frontend/public/vite.svg +1 -0
- package/frontend/src/App.tsx +24 -0
- package/frontend/src/assets/react.svg +1 -0
- package/frontend/src/components/Layout.tsx +59 -0
- package/frontend/src/components/ui/AlertDialog.tsx +47 -0
- package/frontend/src/components/ui/Button.tsx +61 -0
- package/frontend/src/components/ui/CommonAlertDialog.tsx +57 -0
- package/frontend/src/components/ui/FormInput.tsx +73 -0
- package/frontend/src/components/ui/Loader.tsx +7 -0
- package/frontend/src/hook/useFetchUser.ts +38 -0
- package/frontend/src/index.css +1 -0
- package/frontend/src/lib/constants.ts +24 -0
- package/frontend/src/lib/schema.ts +12 -0
- package/frontend/src/lib/utils.ts +71 -0
- package/frontend/src/main.tsx +11 -0
- package/frontend/src/pages/Home.tsx +5 -0
- package/frontend/src/pages/Login.tsx +67 -0
- package/frontend/src/pages/Signup.tsx +67 -0
- package/frontend/src/redux/api/auth.ts +19 -0
- package/frontend/src/redux/slice/auth.ts +39 -0
- package/frontend/src/redux/store.ts +30 -0
- package/frontend/src/routes/index.tsx +20 -0
- package/frontend/src/routes/middleware.ts +18 -0
- package/frontend/src/types/index.ts +12 -0
- package/frontend/src/vite-env.d.ts +1 -0
- package/frontend/tsconfig.app.json +26 -0
- package/frontend/tsconfig.json +7 -0
- package/frontend/tsconfig.node.json +24 -0
- package/frontend/vite.config.ts +19 -0
- package/package.json +34 -0
- package/scripts/setup.js +73 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "backend",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js",
|
|
8
|
+
"dev": "npx --yes nodemon index.js",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"bcrypt": "^5.1.1",
|
|
16
|
+
"cors": "^2.8.5",
|
|
17
|
+
"dotenv": "^16.4.7",
|
|
18
|
+
"express": "^4.21.2",
|
|
19
|
+
"http-status-codes": "^2.3.0",
|
|
20
|
+
"joi": "^17.13.3",
|
|
21
|
+
"jsonwebtoken": "^9.0.2",
|
|
22
|
+
"mongoose": "^8.13.1",
|
|
23
|
+
"morgan": "^1.10.0"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { connect } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
// connection URL
|
|
4
|
+
const url = process.env.MONGODB_URL;
|
|
5
|
+
if (!url) {
|
|
6
|
+
throw new Error("Missing MongoDB connection URL");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// establish connection
|
|
10
|
+
async function connectToDB() {
|
|
11
|
+
try {
|
|
12
|
+
await connect(url);
|
|
13
|
+
console.log("Connected to MongoDB server");
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.log("Server connection issue", error);
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
connectToDB();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { StatusCodes } = require("http-status-codes");
|
|
2
|
+
const { User } = require("../models/user");
|
|
3
|
+
const {
|
|
4
|
+
generateAuthToken,
|
|
5
|
+
encryptPassword,
|
|
6
|
+
comparePassword,
|
|
7
|
+
customError
|
|
8
|
+
} = require("../utils/helper");
|
|
9
|
+
const { MSG_CONSTANTS } = require("../utils/constants");
|
|
10
|
+
|
|
11
|
+
module.exports.register = async (req, res, next) => {
|
|
12
|
+
try {
|
|
13
|
+
const { name, email, password } = req.body;
|
|
14
|
+
|
|
15
|
+
// Check if the user already exists
|
|
16
|
+
const user = await User.findOne({ email });
|
|
17
|
+
if (user)
|
|
18
|
+
throw customError(MSG_CONSTANTS.USER_EXISTS, StatusCodes.BAD_REQUEST);
|
|
19
|
+
|
|
20
|
+
// Create a new user
|
|
21
|
+
const newUser = await User.create({
|
|
22
|
+
name,
|
|
23
|
+
email,
|
|
24
|
+
password: await encryptPassword(password)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Send the authentication token
|
|
28
|
+
res.send({
|
|
29
|
+
message: MSG_CONSTANTS.REGISTER_SUCCESS,
|
|
30
|
+
token: generateAuthToken(newUser)
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
next(error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports.login = async (req, res, next) => {
|
|
38
|
+
try {
|
|
39
|
+
const { email, password } = req.body;
|
|
40
|
+
|
|
41
|
+
// Check if the user exists
|
|
42
|
+
const user = await User.findOne({ email });
|
|
43
|
+
if (!user)
|
|
44
|
+
throw customError(MSG_CONSTANTS.INVALID_CRED, StatusCodes.BAD_REQUEST);
|
|
45
|
+
|
|
46
|
+
// Validate the password
|
|
47
|
+
if (!(await comparePassword(password, user.password)))
|
|
48
|
+
throw customError(MSG_CONSTANTS.INVALID_CRED, StatusCodes.BAD_REQUEST);
|
|
49
|
+
|
|
50
|
+
// Send the authentication token
|
|
51
|
+
res.send({
|
|
52
|
+
message: MSG_CONSTANTS.LOGIN_SUCCESS,
|
|
53
|
+
token: generateAuthToken(user)
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
next(error);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports.profile = (req, res, next) => {
|
|
61
|
+
try {
|
|
62
|
+
const user = req.user;
|
|
63
|
+
|
|
64
|
+
if (!user)
|
|
65
|
+
throw customError(MSG_CONSTANTS.UNAUTHORIZED, StatusCodes.UNAUTHORIZED);
|
|
66
|
+
|
|
67
|
+
res.send(user);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
next(error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const jwt = require("jsonwebtoken");
|
|
2
|
+
const { User } = require("../models/user");
|
|
3
|
+
const { StatusCodes } = require("http-status-codes");
|
|
4
|
+
const { customError } = require("../utils/helper");
|
|
5
|
+
const { MSG_CONSTANTS } = require("../utils/constants");
|
|
6
|
+
const jwtSecretKey = process.env.JWT_SECRET_KEY;
|
|
7
|
+
|
|
8
|
+
async function isAuthenticated(req, res, next) {
|
|
9
|
+
try {
|
|
10
|
+
const auth_token = req.header("Authorization");
|
|
11
|
+
if (!auth_token)
|
|
12
|
+
throw customError(
|
|
13
|
+
MSG_CONSTANTS.TOKEN_MISSING,
|
|
14
|
+
StatusCodes.UNAUTHORIZED
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const token = auth_token.split(" ")[1];
|
|
18
|
+
if (!token)
|
|
19
|
+
throw customError(MSG_CONSTANTS.INVALID_TOKEN, StatusCodes.UNAUTHORIZED);
|
|
20
|
+
|
|
21
|
+
const decoded = jwt.verify(token, jwtSecretKey);
|
|
22
|
+
if (!decoded)
|
|
23
|
+
throw customError(MSG_CONSTANTS.INVALID_TOKEN, StatusCodes.UNAUTHORIZED);
|
|
24
|
+
|
|
25
|
+
// Fetch user and attach to request object
|
|
26
|
+
req.user = await User.findById(decoded.id).select("name email");
|
|
27
|
+
if (!req.user)
|
|
28
|
+
throw customError(MSG_CONSTANTS.INVALID_TOKEN, StatusCodes.UNAUTHORIZED);
|
|
29
|
+
|
|
30
|
+
next();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
next(err);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { isAuthenticated };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { StatusCodes } = require("http-status-codes");
|
|
2
|
+
|
|
3
|
+
function validateBody(schema) {
|
|
4
|
+
return (req, res, next) => {
|
|
5
|
+
const { error } = schema.validate(req.body);
|
|
6
|
+
if (error)
|
|
7
|
+
return res
|
|
8
|
+
.status(StatusCodes.BAD_REQUEST)
|
|
9
|
+
.send({ message: error.details[0].message });
|
|
10
|
+
next();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
validateBody
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { Schema, model } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const userSchema = new Schema({
|
|
4
|
+
name: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
minlength: 2
|
|
8
|
+
},
|
|
9
|
+
email: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
unique: true
|
|
13
|
+
},
|
|
14
|
+
password: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
minlength: 6
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
versionKey: false,
|
|
21
|
+
timestamps: true
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const User = model("Users", userSchema, "Users");
|
|
25
|
+
|
|
26
|
+
module.exports = { User };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Import controllers
|
|
2
|
+
const { register, login, profile } = require("../controller/auth");
|
|
3
|
+
|
|
4
|
+
// Import middlewares
|
|
5
|
+
const { isAuthenticated } = require("../middleware/auth");
|
|
6
|
+
const { validateBody } = require("../middleware/validator");
|
|
7
|
+
|
|
8
|
+
// Import validation schemas
|
|
9
|
+
const { register_schema, login_schema } = require("../utils/schema/auth");
|
|
10
|
+
|
|
11
|
+
// Initialize router
|
|
12
|
+
const router = require("express").Router();
|
|
13
|
+
|
|
14
|
+
// Routes
|
|
15
|
+
// User registration
|
|
16
|
+
router.post("/register", validateBody(register_schema), register);
|
|
17
|
+
|
|
18
|
+
// User login
|
|
19
|
+
router.post("/login", validateBody(login_schema), login);
|
|
20
|
+
|
|
21
|
+
// Get user profile
|
|
22
|
+
router.get("/profile", isAuthenticated, profile);
|
|
23
|
+
|
|
24
|
+
// Export router
|
|
25
|
+
module.exports = router;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const app = express();
|
|
3
|
+
require("./config/db");
|
|
4
|
+
const cors = require("cors");
|
|
5
|
+
const morgan = require("morgan");
|
|
6
|
+
const port = process.env.PORT || 5000;
|
|
7
|
+
|
|
8
|
+
app.use(express.json());
|
|
9
|
+
app.use(cors());
|
|
10
|
+
app.use(morgan("dev"));
|
|
11
|
+
|
|
12
|
+
app.get("/", (req, res) => {
|
|
13
|
+
res.send("Hello, World!");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
app.use("/auth", require("./routes/auth"));
|
|
17
|
+
|
|
18
|
+
app.use((err, req, res, next) => {
|
|
19
|
+
console.log("err: ", err);
|
|
20
|
+
const statusCode = err.status || 500;
|
|
21
|
+
res.status(statusCode).json({
|
|
22
|
+
message: err.message || "Internal Server Error"
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
app.listen(port, () => {
|
|
27
|
+
console.log(`Server running on port: http://localhost:${port}.`);
|
|
28
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const MSG_CONSTANTS = {
|
|
2
|
+
USER_EXISTS: "User already exists",
|
|
3
|
+
INVALID_CRED: "Invalid email or password",
|
|
4
|
+
TOKEN_MISSING: "Authorization token missing.",
|
|
5
|
+
UNAUTHORIZED: "Unauthorized",
|
|
6
|
+
INVALID_TOKEN: "Invalid token",
|
|
7
|
+
|
|
8
|
+
LOGIN_SUCCESS: "Login successful",
|
|
9
|
+
REGISTER_SUCCESS: "Registration successful",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
MSG_CONSTANTS
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const jwt = require("jsonwebtoken");
|
|
2
|
+
const bcrypt = require("bcrypt");
|
|
3
|
+
|
|
4
|
+
function customError(message, statusCode = 500) {
|
|
5
|
+
const error = new Error(message);
|
|
6
|
+
error.status = statusCode;
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Destructure environment variables for better readability
|
|
11
|
+
const { JWT_SECRET_KEY } = process.env;
|
|
12
|
+
if (!JWT_SECRET_KEY) {
|
|
13
|
+
throw new Error("JWT_SECRET_KEY is not defined in environment variables");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const generateAuthToken = (user) => {
|
|
17
|
+
return jwt.sign(
|
|
18
|
+
{ id: user._id }, // Payload
|
|
19
|
+
JWT_SECRET_KEY, // Secret key
|
|
20
|
+
{ expiresIn: "1h" } // Token expiration
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const encryptPassword = async (pass) => bcrypt.hash(pass, 10);
|
|
25
|
+
|
|
26
|
+
const comparePassword = async (pass, hashPass) =>
|
|
27
|
+
bcrypt.compare(pass, hashPass);
|
|
28
|
+
|
|
29
|
+
// Export utility functions
|
|
30
|
+
module.exports = { customError, generateAuthToken, encryptPassword, comparePassword };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const Joi = require("joi");
|
|
2
|
+
|
|
3
|
+
const MSG = {
|
|
4
|
+
EMAIL: {
|
|
5
|
+
"string.base": "Email must be a string",
|
|
6
|
+
"string.email": "Email must be a valid email address",
|
|
7
|
+
"any.required": "Email is required"
|
|
8
|
+
},
|
|
9
|
+
PASSWORD: {
|
|
10
|
+
"string.base": "Password must be a string",
|
|
11
|
+
"string.min": "Password must be at least 6 characters long",
|
|
12
|
+
"any.required": "Password is required"
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const register_schema = Joi.object({
|
|
17
|
+
name: Joi.string().min(2).required().messages({
|
|
18
|
+
"string.base": "Name must be a string",
|
|
19
|
+
"string.min": "Name must be at least 2 characters long",
|
|
20
|
+
"any.required": "Name is required"
|
|
21
|
+
}),
|
|
22
|
+
email: Joi.string().required().email().messages(MSG.EMAIL),
|
|
23
|
+
password: Joi.string().min(6).required().messages(MSG.PASSWORD)
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const login_schema = Joi.object({
|
|
27
|
+
email: Joi.string().required().email().messages(MSG.EMAIL),
|
|
28
|
+
password: Joi.string().min(6).required().messages(MSG.PASSWORD)
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
register_schema,
|
|
33
|
+
login_schema
|
|
34
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
6
|
+
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
|
7
|
+
|
|
8
|
+
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
12
|
+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
13
|
+
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
14
|
+
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
|
15
|
+
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
16
|
+
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
17
|
+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
18
|
+
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
|
19
|
+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
|
20
|
+
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
|
21
|
+
</p>
|
|
22
|
+
<!--[](https://opencollective.com/nest#backer)
|
|
23
|
+
[](https://opencollective.com/nest#sponsor)-->
|
|
24
|
+
|
|
25
|
+
## Description
|
|
26
|
+
|
|
27
|
+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
28
|
+
|
|
29
|
+
## Project setup
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ pnpm install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Compile and run the project
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# development
|
|
39
|
+
$ pnpm run start
|
|
40
|
+
|
|
41
|
+
# watch mode
|
|
42
|
+
$ pnpm run start:dev
|
|
43
|
+
|
|
44
|
+
# production mode
|
|
45
|
+
$ pnpm run start:prod
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Run tests
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# unit tests
|
|
52
|
+
$ pnpm run test
|
|
53
|
+
|
|
54
|
+
# e2e tests
|
|
55
|
+
$ pnpm run test:e2e
|
|
56
|
+
|
|
57
|
+
# test coverage
|
|
58
|
+
$ pnpm run test:cov
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Deployment
|
|
62
|
+
|
|
63
|
+
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
|
64
|
+
|
|
65
|
+
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
$ pnpm install -g mau
|
|
69
|
+
$ mau deploy
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
|
73
|
+
|
|
74
|
+
## Resources
|
|
75
|
+
|
|
76
|
+
Check out a few resources that may come in handy when working with NestJS:
|
|
77
|
+
|
|
78
|
+
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
|
79
|
+
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
|
80
|
+
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
|
81
|
+
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
|
82
|
+
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
|
83
|
+
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
|
84
|
+
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
|
85
|
+
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
|
86
|
+
|
|
87
|
+
## Support
|
|
88
|
+
|
|
89
|
+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
90
|
+
|
|
91
|
+
## Stay in touch
|
|
92
|
+
|
|
93
|
+
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
|
94
|
+
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
95
|
+
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import eslint from '@eslint/js';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{
|
|
9
|
+
ignores: ['eslint.config.mjs'],
|
|
10
|
+
},
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
13
|
+
eslintPluginPrettierRecommended,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.node,
|
|
18
|
+
...globals.jest,
|
|
19
|
+
},
|
|
20
|
+
ecmaVersion: 5,
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
parserOptions: {
|
|
23
|
+
projectService: true,
|
|
24
|
+
tsconfigRootDir: import.meta.dirname,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
rules: {
|
|
30
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
31
|
+
'@typescript-eslint/no-floating-promises': 'warn',
|
|
32
|
+
'@typescript-eslint/no-unsafe-argument': 'warn'
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "boiler-plate",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"private": true,
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "nest build",
|
|
10
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
11
|
+
"start": "nest start",
|
|
12
|
+
"start:dev": "nest start --watch",
|
|
13
|
+
"start:debug": "nest start --debug --watch",
|
|
14
|
+
"start:prod": "node dist/main",
|
|
15
|
+
"prisma:studio": "cd src/core/prisma && prisma studio",
|
|
16
|
+
"prisma:generate": "cd src/core/prisma && prisma generate",
|
|
17
|
+
"prisma:migrate": "node src/scripts/migrate.js",
|
|
18
|
+
"docker": "docker compose up -d",
|
|
19
|
+
"docker:down": "docker compose down",
|
|
20
|
+
"docker:remove": "docker compose down -v",
|
|
21
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"test:watch": "jest --watch",
|
|
24
|
+
"test:cov": "jest --coverage",
|
|
25
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
26
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@nestjs/common": "^11.0.1",
|
|
30
|
+
"@nestjs/config": "^4.0.1",
|
|
31
|
+
"@nestjs/core": "^11.0.1",
|
|
32
|
+
"@nestjs/jwt": "^11.0.0",
|
|
33
|
+
"@nestjs/mapped-types": "^2.1.0",
|
|
34
|
+
"@nestjs/platform-express": "^11.0.1",
|
|
35
|
+
"@prisma/client": "^6.5.0",
|
|
36
|
+
"bcrypt": "^5.1.1",
|
|
37
|
+
"class-transformer": "^0.5.1",
|
|
38
|
+
"class-validator": "^0.14.1",
|
|
39
|
+
"reflect-metadata": "^0.2.2",
|
|
40
|
+
"rxjs": "^7.8.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
44
|
+
"@eslint/js": "^9.18.0",
|
|
45
|
+
"@nestjs/cli": "^11.0.0",
|
|
46
|
+
"@nestjs/schematics": "^11.0.0",
|
|
47
|
+
"@nestjs/testing": "^11.0.1",
|
|
48
|
+
"@swc/cli": "^0.6.0",
|
|
49
|
+
"@swc/core": "^1.10.7",
|
|
50
|
+
"@types/bcrypt": "^5.0.2",
|
|
51
|
+
"@types/express": "^5.0.0",
|
|
52
|
+
"@types/jest": "^29.5.14",
|
|
53
|
+
"@types/node": "^22.10.7",
|
|
54
|
+
"@types/supertest": "^6.0.2",
|
|
55
|
+
"eslint": "^9.18.0",
|
|
56
|
+
"eslint-config-prettier": "^10.0.1",
|
|
57
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
58
|
+
"globals": "^15.14.0",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"prettier": "^3.4.2",
|
|
61
|
+
"prisma": "^6.5.0",
|
|
62
|
+
"source-map-support": "^0.5.21",
|
|
63
|
+
"supertest": "^7.0.0",
|
|
64
|
+
"ts-jest": "^29.2.5",
|
|
65
|
+
"ts-loader": "^9.5.2",
|
|
66
|
+
"ts-node": "^10.9.2",
|
|
67
|
+
"tsconfig-paths": "^4.2.0",
|
|
68
|
+
"typescript": "^5.7.3",
|
|
69
|
+
"typescript-eslint": "^8.20.0"
|
|
70
|
+
},
|
|
71
|
+
"jest": {
|
|
72
|
+
"moduleFileExtensions": [
|
|
73
|
+
"js",
|
|
74
|
+
"json",
|
|
75
|
+
"ts"
|
|
76
|
+
],
|
|
77
|
+
"rootDir": "src",
|
|
78
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
79
|
+
"transform": {
|
|
80
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
81
|
+
},
|
|
82
|
+
"collectCoverageFrom": [
|
|
83
|
+
"**/*.(t|j)s"
|
|
84
|
+
],
|
|
85
|
+
"coverageDirectory": "../coverage",
|
|
86
|
+
"testEnvironment": "node"
|
|
87
|
+
},
|
|
88
|
+
"pnpm": {
|
|
89
|
+
"onlyBuiltDependencies": [
|
|
90
|
+
"@nestjs/core",
|
|
91
|
+
"@prisma/client",
|
|
92
|
+
"@prisma/engines",
|
|
93
|
+
"@swc/core",
|
|
94
|
+
"bcrypt",
|
|
95
|
+
"esbuild",
|
|
96
|
+
"prisma"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|