Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Welcome to the IronLauncher! A quick start for your JavaScript applications.
1. Run the CLI using

```sh
npx ironlaucher@latest # <your-app-name> + flag(s)
npx ironlauncher@latest # <your-app-name> + flag(s)
```

## Help
Expand Down
2 changes: 1 addition & 1 deletion dist/config/ironlauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IronLauncher {
}
get variant() {
if (__classPrivateFieldGet(this, _IronLauncher_auth, "f")) {
return "auth";
return "authentication";
}
return "base";
}
Expand Down
13 changes: 7 additions & 6 deletions dist/core/install/depedencies/base.deps.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BASE_EXPRESS_DEV = exports.baseCookieAuth = exports.baseExpress = void 0;
exports.baseExpress = [`dotenv`, `express`, `mongoose`, `morgan`];
const baseAuth = ["bcrypt"];
exports.baseCookieAuth = [
...baseAuth,
exports.baseExpress = [
`dotenv`,
`express`,
`mongoose`,
`morgan`,
"cookie-parser",
"express-session",
"connect-mongo",
];
const baseAuth = ["bcrypt"];
exports.baseCookieAuth = [...baseAuth, "express-session", "connect-mongo"];
exports.BASE_EXPRESS_DEV = ["nodemon"];
13 changes: 0 additions & 13 deletions dist/utils/cli/cliParse.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ const validator_1 = require("../../core/validator");
const helpText_1 = require("./helpText");
const args = (0, minimist_1.default)(process.argv.slice(2), {});
exports.inputs = args._, exports.__ = args["--"], exports.flags = __rest(args, ["_", "--"]);
// console.log("args:", args);
// console.log("inputs:", inputs);
// export const getFlags = () => {
// let obj = {}
// for (const key in flags) {
// const value = flags[key]
// if (key in flags) {
// if (typeof value === "boolean" || typeof JSON.parse(value) === "boolean") {
// obj[]
// }
// }
// }
// }
const displayHelp = () => {
return exports.inputs.includes("help") || !!args["help"];
};
Expand Down
4 changes: 2 additions & 2 deletions dist/utils/cli/helpText.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const flags = {
},
auth: {
type: "boolean",
desc: `Adds auth behaviour`,
desc: `Adds auth behavior`,
},
fs: {
type: "boolean",
default: false,
desc: "Creates an opinioated express and create-react-app setup",
desc: "Creates an opinionated express and create-react-app setup",
},
};
const commands = {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironlauncher",
"version": "0.35.0",
"version": "0.37.0",
"main": "index.js",
"repository": "git@github.com:ironhack-edu/ironlauncher.git",
"author": "André de Albuquerque (https://itstheandre.com)",
Expand Down
2 changes: 1 addition & 1 deletion src/config/ironlauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class IronLauncher implements IronlauncherConfig {

get variant(): IronLauncherVariant {
if (this.#auth) {
return "auth";
return "authentication";
}
return "base";
}
Expand Down
15 changes: 8 additions & 7 deletions src/core/install/depedencies/base.deps.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export const baseExpress = [`dotenv`, `express`, `mongoose`, `morgan`];
export const baseExpress = [
`dotenv`,
`express`,
`mongoose`,
`morgan`,
"cookie-parser",
];

const baseAuth = ["bcrypt"];

export const baseCookieAuth = [
...baseAuth,
"cookie-parser",
"express-session",
"connect-mongo",
];
export const baseCookieAuth = [...baseAuth, "express-session", "connect-mongo"];

export const BASE_EXPRESS_DEV = ["nodemon"];
4 changes: 2 additions & 2 deletions src/types/IronlauncherConfig.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export interface BaseConfig {
}

export type IronLauncherTemplate = "views" | "json" | "fullstack";
export type IronLauncherVariant = "base" | "auth";
export type IronLauncherVariant = "base" | "authentication";

export interface IronlauncherConfig extends BaseConfig {
init(): Promise<void>;
}

export interface IronlauncherType {
tech: "views" | "json" | "fs";
variant: "auth" | "base";
variant: "authentication" | "base";
}
15 changes: 0 additions & 15 deletions src/utils/cli/cliParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@ import { FLAGS } from "./helpText";
const args = minimist(process.argv.slice(2), {});

export const { _: inputs, "--": __, ...flags } = args;
// console.log("args:", args);
// console.log("inputs:", inputs);

// export const getFlags = () => {
// let obj = {}
// for (const key in flags) {
// const value = flags[key]
// if (key in flags) {
// if (typeof value === "boolean" || typeof JSON.parse(value) === "boolean") {

// obj[]
// }
// }
// }
// }

export const displayHelp = () => {
return inputs.includes("help") || !!args["help"];
Expand Down
11 changes: 8 additions & 3 deletions src/utils/cli/helpText.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MeowHelpFlags, MeowHelpCommands } from "cli-meow-help";
import meowHelp from "cli-meow-help";

export const FLAGS = ["json", "auth", "fs"] as const;
export const FLAGS = ["json", "auth", "fs", "pnpm"] as const;
export type FLAGS_OPTS = typeof FLAGS[number];

const flags: MeowHelpFlags<typeof FLAGS> = {
Expand All @@ -12,12 +12,17 @@ const flags: MeowHelpFlags<typeof FLAGS> = {
},
auth: {
type: "boolean",
desc: `Adds auth behaviour`,
desc: `Adds auth behavior`,
},
fs: {
type: "boolean",
default: false,
desc: "Creates an opinioated express and create-react-app setup",
desc: "Creates an opinionated express and create-react-app setup",
},
pnpm: {
type: "boolean",
default: false,
desc: "Installs dependencies through pnpm, assuming you have it installed",
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require("./config")(app);

// 👇 Start handling routes here
// Contrary to the views version, all routes are controlled from the routes/index.js
const allRoutes = require("./routes");
const allRoutes = require("./routes/index.routes");
app.use("/api", allRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = (app) => {

// only render if the error ocurred before sending the response
if (!res.headersSent) {
res.status(500).json({
errorMessage: "Internal server error. Check the server console",
res.status(err.status || 500).json({
errorMessage: err.message || "Internal server error. Check the server console",
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const saltRounds = 10;
const User = require("../models/User.model");
const Session = require("../models/Session.model");

// Require necessary (isLoggedOut and isLiggedIn) middleware in order to control access to specific routes
// Require necessary (isLoggedOut and isLoggedIn) middleware in order to control access to specific routes
const isLoggedOut = require("../middleware/isLoggedOut");
const isLoggedIn = require("../middleware/isLoggedIn");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const router = require("express").Router();
const authRoutes = require("./auth");
const authRoutes = require("./auth.routes");

/* GET home page */
router.get("/", (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion template/fullstack/base/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require("./config")(app);

// 👇 Start handling routes here
// Contrary to the views version, all routes are controlled from the routes/index.js
const allRoutes = require("./routes");
const allRoutes = require("./routes/index.routes");
app.use("/api", allRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
Expand Down
4 changes: 2 additions & 2 deletions template/fullstack/base/server/error-handling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module.exports = (app) => {
// only render if the error ocurred before sending the response
if (!res.headersSent) {
res
.status(500)
.status(err.status || 500)
.json({
errorMessage: "Internal server error. Check the server console",
errorMessage: err.message || "Internal server error. Check the server console",
});
}
});
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require("./config")(app);

// 👇 Start handling routes here
// Contrary to the views version, all routes are controlled from the routes/index.js
const allRoutes = require("./routes");
const allRoutes = require("./routes/index.routes");
app.use("/api", allRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = (app) => {

// only render if the error ocurred before sending the response
if (!res.headersSent) {
res.status(500).json({
errorMessage: "Internal server error. Check the server console",
res.status(err.status || 500).json({
errorMessage: err.message || "Internal server error. Check the server console",
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const saltRounds = 10;
// Require the User model in order to interact with the database
const User = require("../models/User.model");

// Require necessary (isLoggedOut and isLiggedIn) middleware in order to control access to specific routes
// Require necessary (isLoggedOut and isLoggedIn) middleware in order to control access to specific routes
const isLoggedOut = require("../middleware/isLoggedOut");
const isLoggedIn = require("../middleware/isLoggedIn");

Expand All @@ -28,9 +28,9 @@ router.post("/signup", isLoggedOut, (req, res) => {
}

if (password.length < 8) {
return res.status(400).json({
errorMessage: "Your password needs to be at least 8 characters long.",
});
return res
.status(400)
.json({ errorMessage: "Your password needs to be at least 8 characters long." });
}

// ! This use case is using a regular expression to control for special characters and min length
Expand All @@ -49,7 +49,9 @@ router.post("/signup", isLoggedOut, (req, res) => {
User.findOne({ username }).then((found) => {
// If the user is found, send the message username is taken
if (found) {
return res.status(400).json({ errorMessage: "Username already taken." });
return res
.status(400)
.json({ errorMessage: "Username already taken." });
}

// if user is not found, create a new user - start with hashing the password
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const router = require("express").Router();
const authRoutes = require("./auth");
const authRoutes = require("./auth.routes");

/* GET home page */
router.get("/", (req, res, next) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion template/json/base/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require("./config")(app);

// 👇 Start handling routes here
// Contrary to the views version, all routes are controlled from the routes/index.js
const allRoutes = require("./routes");
const allRoutes = require("./routes/index.routes");
app.use("/api", allRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
Expand Down
4 changes: 2 additions & 2 deletions template/json/base/error-handling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module.exports = (app) => {
// only render if the error ocurred before sending the response
if (!res.headersSent) {
res
.status(500)
.status(err.status || 500)
.json({
errorMessage: "Internal server error. Check the server console",
errorMessage: err.message || "Internal server error. Check the server console",
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion template/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{{title}}</title>
<title>{{appTitle}}</title>
<link rel="stylesheet" href="/stylesheets/style.css" />
</head>

Expand Down
2 changes: 0 additions & 2 deletions template/views/auth/views/index.hbs

This file was deleted.

19 changes: 0 additions & 19 deletions template/views/auth/views/layout.hbs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const app = express();
// ℹ️ This function is getting exported from the config folder. It runs most pieces of middleware
require("./config")(app);

const capitalized = require("./utils/capitalized");
const projectName = "{{name}}";
const capitalized = (string) => string[0].toUpperCase() + string.slice(1).toLowerCase();

app.locals.title = `${capitalized(projectName)} created with IronLauncher`;
app.locals.appTitle = `${capitalized(projectName)} created with IronLauncher`;

// 👇 Start handling routes here
const index = require("./routes/index");
const index = require("./routes/index.routes");
app.use("/", index);

const authRoutes = require("./routes/auth");
const authRoutes = require("./routes/auth.routes");
app.use("/auth", authRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (app) => {

// only render if the error ocurred before sending the response
if (!res.headersSent) {
res.status(500).res.render("error");
res.status(err.status || 500).res.render("error");
}
});
};
Loading