Skip to content

Commit 218f9ad

Browse files
committed
Fix: remove unnecessary to starter code
1 parent 998eaef commit 218f9ad

File tree

9 files changed

+77
-207
lines changed

9 files changed

+77
-207
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ next-env.d.ts
4343
/.husky/
4444

4545
#bin
46-
/bin/*
46+
/bin/cli.js

backend/controllers/eventController.ts

Lines changed: 0 additions & 152 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ts-nocheck
2+
import { NextApiRequest, NextApiResponse } from 'next'
3+
import UserModel, { IEvent } from '../models/eventModel'
4+
import mongoose from 'mongoose'
5+
6+
export const getUser = async (req: NextApiRequest, res: NextApiResponse) => {
7+
const eventId = req.query.id as string
8+
9+
if (!mongoose.Types.ObjectId.isValid(eventId)) {
10+
res.status(404).json({ error: 'No such Event' })
11+
return
12+
}
13+
14+
try {
15+
const user: IEvent | null = await UserModel.findById(eventId)
16+
if (!user) {
17+
res.status(404).json({ error: 'No such user' })
18+
return
19+
}
20+
res.status(200).json(user.toJSON())
21+
} catch (error) {
22+
res.status(500).json({ error: 'Internal Server Error' })
23+
}
24+
}

backend/models/eventModel.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

backend/models/userModel.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import mongoose, { Schema, Document, Model } from 'mongoose'
2+
3+
mongoose.Promise = global.Promise
4+
5+
enum Role {
6+
ADMIN = 'admin',
7+
USER = 'user',
8+
EDITOR = 'editor',
9+
}
10+
11+
// Define the User interface to represent the document structure
12+
interface User extends Document {
13+
username: string
14+
email: string
15+
password: string
16+
role: Role
17+
createdAt: Date
18+
updatedAt: Date
19+
}
20+
21+
// Define the schema for the User model
22+
const userSchema = new Schema<User>(
23+
{
24+
username: {
25+
type: String,
26+
required: true,
27+
unique: true,
28+
},
29+
email: {
30+
type: String,
31+
required: true,
32+
unique: true,
33+
},
34+
password: {
35+
type: String,
36+
required: true,
37+
},
38+
},
39+
{ timestamps: true } // Automatically add createdAt and updatedAt fields
40+
)
41+
42+
// Create and export the User model
43+
// Check if the model is already registered
44+
45+
export default mongoose.models.User
46+
? mongoose.model('User')
47+
: (mongoose.model<User>('User', userSchema) as Model<User>)

bin/cli.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ function runCommandWithLoading(command, loadingMessage, colorCode) {
2323
}
2424
}
2525

26-
console.log(colorizeText(`Cloning the repository ... ${repoName}`, '34')) // Blue color for cloning
2726
runCommandWithLoading(gitCheckoutCommand, 'Cloning the repository', '34')
2827

29-
console.log(colorizeText(`Installing dependencies for ${repoName}`, '36')) // Cyan color for installing
3028
runCommandWithLoading(installDepsCommand, 'Installing dependencies', '36')
3129

3230
console.log(colorizeText('Congratulations! You are ready to go.', '32')) // Green color for success
3331
console.log('To start the project, run the following commands:')
34-
console.log(`cd ${repoName} && npm run dev`)
35-
console.log(colorizeText('Your project will be available at http://localhost:3050', '33')) // Yellow color for info
32+
console.log(colorizeText(`cd ${repoName} && npm run dev`, '35'))
33+
console.log(colorizeText('Your project will be available at', '33')) // Yellow color for info
34+
console.log(colorizeText('http://localhost:3050', '33')) // Yellow color for info
3635

3736
function exitProcess(code) {
3837
process.exit(code)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-typescript-redux-starter",
3-
"version": "1.0.5",
3+
"version": "1.0.8",
44
"bin": "./bin/cli.js",
55
"scripts": {
66
"dev": "next dev -p 3050",

src/lib/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SIZE_TYPE, VARIANT_TYPE } from './constants'
22

3+
// example uses
34
const SETTINGS = {
45
inputSize: SIZE_TYPE.SM,
56
inputVariant: VARIANT_TYPE.OUTLINED,

src/styles/globals.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ body {
1313
background: var(--background)
1414
}
1515

16-
17-
1816
.auto-column-grid {
1917
display: grid;
2018
grid-gap: 15px;

0 commit comments

Comments
 (0)