loading...

Day 4 [D&D Character Sheets]

approachingapathy profile image Ephriam Henderson ・2 min read

Report

Yay! Server and initial database setup is done. From now on I can focus on actually building out the app! I got hung up for a while before I realized I was calling app.use() in the wrong place.

I had it here(see below). Which meant it wouldn't trigger for any of my routes! The app would get to my router module and execute my routes before attaching the db object to the request. I wasted a lot of time overlooking this.

// index.js
app.use(require("./router"));
app.use(async (req, res, next) => {
    const db = await dbPromise;
    req.context = { ...db };
    next();
});

The fix was this simple:

// index.js
app.use(async (req, res, next) => {
    const db = await dbPromise;
    req.context = { ...db };
    next();
});
app.use(require("./router"));

Once that was done I had my database accessible throughout my whole server wrote my first simple view to test the connection.

// router/users/index.js
router.get("/", (req, res) => {
    req.context.models.Player.find().then(players => {
        res.render("users", {
            data: {
                users: players || []
            }
        });
    });
});
// views/users.ejs
<% data.users.forEach(user => { %>
    <li><%= user.username %></li>
<% }); %>

I've only been working an hour each day, so getting this setup felt like it took forever. Tomorrow I'd like to spend some time getting some type of character sheet view working.

Project

[100days] The DND Character Sheet App

This is the first project of my 100 days of coding This is an app to keep D&D character sheets.

Stack

I'll be using Node.js and building a full-stack Express app with MongoDB.

Requirements

Minimum Viable

  • Present a D&D Character Sheet
    • The sheet should display all the same info as the first page of the 5e Official sheet.
  • Users should be able to log in and create player-characters.
  • Users should be able to edit character sheets.
  • Users should be able to organize character sheets into groups (parties/tables)
  • Sheets should auto calculate basic stats like ability modifiers
    • Support Proficiency Bonuses

Cake

  • Extend character creation to allow the user to use any of the three common stat gen methods
    • Point Buy
    • Standard Array
    • Roll
  • Extend the character sheet to all the info in the 5e official sheet.
  • Allow for image uploads for character portraits.
  • Allow for…

The First project will be an app to keep D&D character sheets.

Stack

I'll be using Node.js and building a full-stack Express app with MongoDB.

Requirements

Minimum Viable

  • [ ] Present a D&D Character Sheet
    • [ ] The sheet should display all the same info as the first page of the 5e Official sheet.
  • [ ] Users should be able to log in and create player-characters.
  • [ ] Users should be able to edit character sheets.
  • [ ] Users should be able to organize character sheets into groups (parties/tables)
  • [ ] Sheets should auto calculate basic stats like ability modifiers.
    • [ ] Support Proficiency Bonuses

Cake

  • [ ] Extend character creation to allow the user to use any of the three common stat gen methods.
    • [ ] Point Buy
    • [ ] Standard Array
    • [ ] Roll
  • [ ] Extend the character sheet to all the info in the 5e official sheet.
  • [ ] Allow for image uploads for character portraits.
  • [ ] Allow for extended descriptions/backstories.
    • [ ] Characters should have nice full page backstories.
    • [ ] Preferably use a markdown editor.

Posted on by:

approachingapathy profile

Ephriam Henderson

@approachingapathy

I'm a Full-Stack Developer and recent Bootcamp Graduate. I'm most experienced with JavaScript, but I'm a python enthusiast and an all-around nerd. When I'm not coding I love anime, sci-fi, d&d.

Discussion

markdown guide