File tree 11 files changed +61
-44
lines changed
11 files changed +61
-44
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " scaffold-api" ,
3
- "version" : " 1.1.3 " ,
3
+ "version" : " 1.1.4 " ,
4
4
"description" : " Scaffold CLI" ,
5
5
"main" : " build/index.js" ,
6
6
"type" : " module" ,
24
24
"keywords" : [
25
25
" cli" ,
26
26
" scaffold" ,
27
- " api"
27
+ " api" ,
28
+ " generator" ,
29
+ " boilerplate" ,
30
+ " nodejs" ,
31
+ " typescript" ,
32
+ " javascript" ,
33
+ " backend" ,
34
+ " framework" ,
35
+ " express" ,
36
+ " fastify" ,
37
+ " mysql" ,
38
+ " postgresql" ,
39
+ " mongodb" ,
40
+ " database" ,
41
+ " rest-api" ,
42
+ " developer-tools" ,
43
+ " productivity" ,
44
+ " automation" ,
45
+ " template" ,
46
+ " project-setup" ,
47
+ " node" ,
48
+ " node-js" ,
49
+ " command-line" ,
50
+ " command-line-tool" ,
51
+ " command-line-interface" ,
52
+ " open-source"
28
53
],
29
54
"license" : " MIT" ,
30
55
"dependencies" : {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import ck from "chalk";
2
2
3
3
export const messages = {
4
4
"en-US" : {
5
- mainMenuTitle : "⚙️ Scaffold CLI 📦 1.1.3 " ,
5
+ mainMenuTitle : "⚙️ Scaffold CLI 📦 1.1.4 " ,
6
6
createProject : "◈ Create API Project" ,
7
7
settings : "☰ Settings" ,
8
8
quit : "✕ Quit" ,
@@ -30,7 +30,7 @@ export const messages = {
30
30
byeMessage : "👋 Goodbye!"
31
31
} ,
32
32
"pt-BR" : {
33
- mainMenuTitle : "⚙️ Scaffold CLI 📦 1.1.3 " ,
33
+ mainMenuTitle : "⚙️ Scaffold CLI 📦 1.1.4 " ,
34
34
createProject : "◈ Criar Projeto de API" ,
35
35
settings : "☰ Configurações" ,
36
36
quit : "✕ Sair" ,
Original file line number Diff line number Diff line change
1
+ MONGO_URI =
Original file line number Diff line number Diff line change 3
3
"version" : " 1.0.0" ,
4
4
"type" : " module" ,
5
5
"scripts" : {
6
- "build" : " tsc && node fix-imports.js" ,
7
- "start" : " node build/app.js" ,
8
- "dev" : " ts-node src/server.ts"
6
+ "dev" : " tsx watch src/server.ts"
9
7
},
10
8
"dependencies" : {
11
9
"dotenv" : " ^16.3.1" ,
12
10
"express" : " ^4.18.2" ,
13
- "mongoose" : " ^8.0.3"
11
+ "mongoose" : " ^8.0.3" ,
12
+ "cors" : " ^2.8.5"
14
13
},
15
14
"devDependencies" : {
16
15
"@types/express" : " ^4.17.21" ,
Original file line number Diff line number Diff line change 1
1
import express from "express" ;
2
+ import cors from "cors"
2
3
import routes from "./appModule.js" ;
3
- import connectDB from "./database/index .js" ;
4
+ import connectDB from "./config/database .js" ;
4
5
5
- const app = express ( ) ;
6
+ class AppController {
7
+ public app : express . Application ;
6
8
7
- app . use ( express . json ( ) ) ;
9
+ constructor ( ) {
10
+ this . app = express ( ) ;
11
+ this . database ( ) ;
12
+ this . middlewares ( ) ;
13
+ this . routes ( ) ;
14
+ }
8
15
9
- connectDB ( ) ;
16
+ private async database ( ) : Promise < void > {
17
+ await connectDB ( ) ;
18
+ }
10
19
11
- app . use ( "/api" , routes ) ;
20
+ private middlewares ( ) : void {
21
+ this . app . use ( express . json ( ) ) ;
22
+ this . app . use ( cors ( ) ) ;
23
+ }
12
24
13
- export default app ;
25
+ private routes ( ) : void {
26
+ this . app . use ( routes ) ;
27
+ }
28
+ }
29
+
30
+ export default new AppController ( ) . app ;
Original file line number Diff line number Diff line change 1
1
import mongoose from "mongoose" ;
2
- import { config } from "dotenv" ;
2
+ import dotenv from "dotenv" ;
3
3
4
- config ( ) ;
4
+ dotenv . config ( ) ;
5
5
6
6
const MONGO_URI = process . env . MONGO_URI as string ;
7
7
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ config();
6
6
const PORT = process . env . PORT || 3000 ;
7
7
8
8
app . listen ( PORT , ( ) => {
9
- console . log ( `Servidor rodando na porta ${ PORT } ` ) ;
10
- } ) ;
9
+ console . log ( `Server running on port ${ PORT } ` ) ;
10
+ } ) ;
File renamed without changes.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class AppController {
15
15
16
16
private async database ( ) : Promise < void > {
17
17
try {
18
- await pool . raw ( "SELECT 1" ) ;
18
+ await pool . query ( "SELECT 1" ) ;
19
19
console . log ( "📦 Banco de dados conectado com sucesso!" ) ;
20
20
} catch ( error ) {
21
21
console . error ( "❌ Erro ao conectar no banco de dados:" , error ) ;
File renamed without changes.
You can’t perform that action at this time.
0 commit comments