create-express-react-mongo 1.0.1 → 1.0.3

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.
Files changed (30) hide show
  1. package/README.md +14 -8
  2. package/bin/index.ts +3 -2
  3. package/dist/index.js +3 -2
  4. package/package.json +1 -1
  5. package/templates/default/client/package-lock.json +2 -2
  6. package/templates/default/server/package-lock.json +2 -2
  7. package/templates/default/client/src/App.d.ts +0 -4
  8. package/templates/default/client/src/App.d.ts.map +0 -1
  9. package/templates/default/client/src/App.js +0 -17
  10. package/templates/default/client/src/App.js.map +0 -1
  11. package/templates/default/client/src/components/index.d.ts +0 -5
  12. package/templates/default/client/src/components/index.d.ts.map +0 -1
  13. package/templates/default/client/src/components/index.js +0 -7
  14. package/templates/default/client/src/components/index.js.map +0 -1
  15. package/templates/default/client/src/main.d.ts +0 -2
  16. package/templates/default/client/src/main.d.ts.map +0 -1
  17. package/templates/default/client/src/main.js +0 -7
  18. package/templates/default/client/src/main.js.map +0 -1
  19. package/templates/default/client/src/services/initialContent.d.ts +0 -6
  20. package/templates/default/client/src/services/initialContent.d.ts.map +0 -1
  21. package/templates/default/client/src/services/initialContent.js +0 -30
  22. package/templates/default/client/src/services/initialContent.js.map +0 -1
  23. package/templates/default/client/vite.config.d.ts +0 -3
  24. package/templates/default/client/vite.config.d.ts.map +0 -1
  25. package/templates/default/client/vite.config.js +0 -7
  26. package/templates/default/client/vite.config.js.map +0 -1
  27. package/templates/default/server/src/index.d.ts +0 -2
  28. package/templates/default/server/src/index.d.ts.map +0 -1
  29. package/templates/default/server/src/index.js +0 -56
  30. package/templates/default/server/src/index.js.map +0 -1
package/README.md CHANGED
@@ -1,10 +1,16 @@
1
- # react-express-mongo
1
+ # express-react-mongo
2
2
 
3
3
 
4
- | Package | Purpose |
5
- | -------- | ----------------------- |
6
- | fs-extra | Copy files easily |
7
- | chalk | Colored terminal output |
8
- | ora | Spinner |
9
- | prompts | CLI questions |
10
- | execa | Run shell commands |
4
+ ## To use this run the following command:
5
+
6
+ ```
7
+ npm create express-react-mongo@1.0.3
8
+ ```
9
+ - Go to client folder:
10
+ - npm install
11
+ - create .env file with VITE_BACKEND_URL -> default is already given inside the code (you can search the name in the code)
12
+ - npm run dev
13
+ - Go to server folder:
14
+ - npm install
15
+ - create .env file with PORT, DB_URL and SESSION_SECRET -> default is already given inside the code (you can search the name in the code)
16
+ - npm run start
package/bin/index.ts CHANGED
@@ -10,7 +10,7 @@ import { fileURLToPath } from "node:url";
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
12
12
 
13
- console.log("CLI CREATED!!")
13
+ console.log("CLI CREATION STARTED!!")
14
14
 
15
15
  async function main() {
16
16
  console.log(
@@ -50,7 +50,8 @@ async function main() {
50
50
  Next steps:
51
51
 
52
52
  cd ${projectName}
53
- npm run dev
53
+ cd client -> npm install -> npm run dev
54
+ cd server -> npm install -> npm run start
54
55
  `);
55
56
  }
56
57
 
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { execa } from "execa";
7
7
  import { fileURLToPath } from "node:url";
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
10
- console.log("CLI CREATED!!");
10
+ console.log("CLI CREATION STARTED!!");
11
11
  async function main() {
12
12
  console.log(chalk.green("\n Creating Express-React-Mongo app\n"));
13
13
  const response = await prompts({
@@ -32,7 +32,8 @@ async function main() {
32
32
  Next steps:
33
33
 
34
34
  cd ${projectName}
35
- npm run dev
35
+ cd client -> npm install -> npm run dev
36
+ cd server -> npm install -> npm run start
36
37
  `);
37
38
  }
38
39
  main().catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-react-mongo",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-express-react-mongo": "./dist/index.js"
@@ -1,11 +1,11 @@
1
1
  {
2
- "name": "client",
2
+ "name": "create-react-express-mongo",
3
3
  "version": "1.0.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
- "name": "client",
8
+ "name": "create-react-express-mongo",
9
9
  "version": "1.0.0",
10
10
  "dependencies": {
11
11
  "@emotion/react": "^11.14.0",
@@ -1,11 +1,11 @@
1
1
  {
2
- "name": "react-express-mongo",
2
+ "name": "create-react-express-mongo",
3
3
  "version": "1.0.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
- "name": "react-express-mongo",
8
+ "name": "create-react-express-mongo",
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
@@ -1,4 +0,0 @@
1
- import './App.css';
2
- declare function App(): import("react/jsx-runtime").JSX.Element;
3
- export default App;
4
- //# sourceMappingURL=App.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAA;AAKlB,iBAAS,GAAG,4CAoBX;AAED,eAAe,GAAG,CAAA"}
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import './App.css';
3
- import LandingPage from './components';
4
- import { BrowserRouter, Routes, Route } from 'react-router-dom';
5
- import { GetInitialContent } from './services/initialContent';
6
- function App() {
7
- const { loading, error, initialContent } = GetInitialContent();
8
- if (loading) {
9
- return _jsx("div", { children: "Loading initial content..." });
10
- }
11
- if (error) {
12
- return _jsx("div", { children: "Unable to load initial content." });
13
- }
14
- return (_jsx(BrowserRouter, { children: _jsx("div", { className: "App", children: _jsx(Routes, { children: _jsx(Route, { path: "/", element: _jsx(LandingPage, { initialContentData: initialContent }) }) }) }) }));
15
- }
16
- export default App;
17
- //# sourceMappingURL=App.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.js","sourceRoot":"","sources":["App.tsx"],"names":[],"mappings":";AAAA,OAAO,WAAW,CAAA;AAClB,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,SAAS,GAAG;IACV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE/D,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,uDAAqC,CAAC;IAC/C,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,4DAA0C,CAAC;IACpD,CAAC;IAED,OAAO,CACL,KAAC,aAAa,cACZ,cAAK,SAAS,EAAC,KAAK,YAClB,KAAC,MAAM,cACL,KAAC,KAAK,IAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,KAAC,WAAW,IAAC,kBAAkB,EAAE,cAAc,GAAG,GAAI,GACxE,GACL,GACQ,CACjB,CAAC;AACJ,CAAC;AAED,eAAe,GAAG,CAAA"}
@@ -1,5 +0,0 @@
1
- declare function LandingPage(props: Readonly<{
2
- initialContentData: any;
3
- }>): import("react/jsx-runtime").JSX.Element;
4
- export default LandingPage;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAE,KAAK,EAAE,QAAQ,CAAC;IAAE,kBAAkB,EAAE,GAAG,CAAC;CAAE,CAAC,2CASlE;AAED,eAAe,WAAW,CAAC"}
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- function LandingPage(props) {
3
- const { initialContentData } = props;
4
- return (_jsxs(_Fragment, { children: [_jsx("h1", { children: initialContentData.title }), _jsx("p", { children: initialContentData.description })] }));
5
- }
6
- export default LandingPage;
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAAA,SAAS,WAAW,CAAE,KAA6C;IAC/D,MAAM,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAErC,OAAO,CACH,8BACI,uBAAK,kBAAkB,CAAC,KAAK,GAAM,EACnC,sBAAI,kBAAkB,CAAC,WAAW,GAAK,IACxC,CACN,CAAA;AACL,CAAC;AAED,eAAe,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- import './index.css';
2
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.tsx"],"names":[],"mappings":"AAGA,OAAO,aAAa,CAAA"}
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
- import ReactDOM from 'react-dom/client';
4
- import App from './App';
5
- import './index.css';
6
- ReactDOM.createRoot(document.getElementById('root')).render(_jsx(React.StrictMode, { children: _jsx(App, {}) }));
7
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["main.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,MAAM,kBAAkB,CAAA;AACvC,OAAO,GAAG,MAAM,OAAO,CAAA;AACvB,OAAO,aAAa,CAAA;AAEpB,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAE,CAAC,CAAC,MAAM,CAC1D,KAAC,KAAK,CAAC,UAAU,cACf,KAAC,GAAG,KAAG,GACU,CACpB,CAAA"}
@@ -1,6 +0,0 @@
1
- export declare function GetInitialContent(): {
2
- initialContent: Record<string, any>;
3
- loading: boolean;
4
- error: unknown;
5
- };
6
- //# sourceMappingURL=initialContent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initialContent.d.ts","sourceRoot":"","sources":["initialContent.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB;;;;EA0BhC"}
@@ -1,30 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import axios from "axios";
3
- export function GetInitialContent() {
4
- const [initialContent, setInitialContent] = useState({});
5
- const [loading, setLoading] = useState(true);
6
- const [error, setError] = useState(null);
7
- const backendUrl = import.meta.env.VITE_BACKEND_URL || "http://localhost:3000";
8
- let isApiProccessed = false;
9
- useEffect(() => {
10
- const fetchInitialContent = async () => {
11
- try {
12
- const response = await axios.get(`${backendUrl}/initial-content`);
13
- setInitialContent(response.data);
14
- }
15
- catch (fetchError) {
16
- setError(fetchError);
17
- }
18
- finally {
19
- setLoading(false);
20
- }
21
- };
22
- // isApiProccessed is checking if Api ran one time it will not run it again. So, you can use this if your Api called two times on load
23
- if (!isApiProccessed) {
24
- isApiProccessed = true;
25
- fetchInitialContent();
26
- }
27
- }, []);
28
- return { initialContent, loading, error };
29
- }
30
- //# sourceMappingURL=initialContent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initialContent.js","sourceRoot":"","sources":["initialContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,iBAAiB;IAC/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAU,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,GACX,MAAM,CAAC,IAAY,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;IACzE,IAAI,eAAe,GAAG,KAAK,CAAC;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;YACrC,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,GAAG,UAAU,kBAAkB,CAChC,CAAC;gBACF,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;YAAC,OAAO,UAAU,EAAE,CAAC;gBACpB,QAAQ,CAAC,UAAU,CAAC,CAAC;YACvB,CAAC;oBAAS,CAAC;gBACT,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;QACF,sIAAsI;QACtI,IAAG,CAAC,eAAe,EAAE,CAAC;YAAA,eAAe,GAAG,IAAI,CAAC;YAAC,mBAAmB,EAAE,CAAC;QAAA,CAAC;IACvE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC"}
@@ -1,3 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
3
- //# sourceMappingURL=vite.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["vite.config.ts"],"names":[],"mappings":";AAIA,wBAEE"}
@@ -1,7 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import react from '@vitejs/plugin-react';
3
- // https://vitejs.dev/config/
4
- export default defineConfig({
5
- plugins: [react()],
6
- });
7
- //# sourceMappingURL=vite.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.config.js","sourceRoot":"","sources":["vite.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,6BAA6B;AAC7B,eAAe,YAAY,CAAC;IAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC;CACnB,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":""}
@@ -1,56 +0,0 @@
1
- import express from "express";
2
- const app = express();
3
- import dotenv from "dotenv";
4
- import MongoStore from "connect-mongo";
5
- import expressSession from "express-session";
6
- import mongoose from "mongoose";
7
- dotenv.config();
8
- app.disable('x-powered-by'); // This will remove the X-Powered-By header, which can help to prevent attackers from identifying the server software being used.
9
- const port = process.env.PORT || 3000;
10
- const dbUrl = process.env.DB_URL || "mongodb://localhost:27017/react-express-mongo";
11
- const sessionSecret = process.env.SESSION_SECRET || "";
12
- async function startServer() {
13
- try {
14
- await mongoose.connect(dbUrl);
15
- console.log("Mongo connection established..");
16
- }
17
- catch (err) {
18
- console.error(err);
19
- console.log("Error in establishing Mongo connection");
20
- }
21
- }
22
- ;
23
- await startServer();
24
- const store = MongoStore.create({
25
- mongoUrl: dbUrl,
26
- ttl: 24 * 60 * 60
27
- });
28
- const session = expressSession({
29
- secret: sessionSecret,
30
- store,
31
- resave: false,
32
- saveUninitialized: false,
33
- });
34
- store.on('error', (error) => {
35
- console.error('Session store error:', error);
36
- });
37
- app.use(session);
38
- app.use(express.json()); // Middleware to parse json
39
- app.use(express.urlencoded());
40
- app.use((req, res, next) => {
41
- const origin = req.headers.origin || 'http://localhost:5173';
42
- const allowedOrigins = ['http://localhost:5173', 'http://localhost:3000'];
43
- if (allowedOrigins.includes(origin)) {
44
- res.setHeader('Access-Control-Allow-Origin', origin);
45
- res.setHeader('Access-Control-Allow-Credentials', 'true');
46
- }
47
- // You can set security headers according to your app
48
- next();
49
- });
50
- app.get('/initial-content', (req, res) => {
51
- res.status(200).send({ title: "Your Express React Mongo App", description: "Congratulations!!! The setup is done. Now you can change or update files according to your need." });
52
- });
53
- app.listen(port, () => {
54
- console.log(`The connection is running on port 3000`);
55
- });
56
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceR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