Share your repls and programming experiences

← Back to all posts
Contacts App (Address Book)
awoolford

This is my first app using Node.js. It is a basic contacts app using the Koa2 framework, Pug for templates, and a sqlite3 database.

app: https://contacts-koa-pug-sqlite--awoolford.repl.co/

repl: https://repl.it/@awoolford/Contacts-koa-pug-sqlite

It's barebones, but might make a decent example of a simple single-table CRUD web app.

I don't know why the database file isn't saved between restarts. It saves the database file when I run the app on my local machine, but not on repl.it.

Comments are welcome, and feel free to fork the repl if the code is useful to you. __

Update (3/30): I've created a second version of this app using Express (better supported by repl.it? maybe?) and MongoDB (hosted by mlab.com). This solves the problem of the sqlite database not being saved between restarts.

app: https://contacts-express-pug-mongodb--awoolford.repl.co/
repl: https://repl.it/@awoolford/Contacts-express-pug-mongodb

Voters
navigator8
JohnsonTheGreat
awoolford
Comments
hotnewtop
JohnsonTheGreat

Can you take me through your process of making this app? In particular, the .npm folder, can it be taken out? What is it's purpose? I'm thinking it was generated during the development process?

awoolford

@johnsonthegreat: Hi. The .npm folder and .config folders are generated by node or repl.it, I didn't put any of that stuff in there. I believe they contain node settings and the all the modules I imported (koa, koa-router, sqlite3, etc).

When I made the app I started with the db.js script to create a sqlite database. Then I did the Koa stuff in index.js.

Here are some sites and tutorials that I learned from.
http://www.sqlitetutorial.net/sqlite-nodejs/
https://www.tutorialspoint.com/koajs/koajs_url_building.htm (this site hasn't updated for Koa version 2 but is still very informative)
https://github.com/koajs/koa/blob/master/docs/migration.md (this helped me make the above tutorial work with Koa version 2)
https://www.tutorialspoint.com/koajs/koajs_templating.htm