Cyper 1d21e48c80 feat: Added instructions for Docker compose
(Secretly, I did not test this at all and hoping for the best)
2026-05-01 22:36:03 -04:00
2026-04-17 00:18:05 -04:00
2026-04-17 00:18:05 -04:00
2026-04-17 00:18:05 -04:00
2026-04-17 00:35:22 -04:00
2026-04-17 00:18:05 -04:00
2026-04-17 00:35:22 -04:00
2026-03-31 03:15:57 +00:00
2026-04-17 00:18:05 -04:00

TypeScriptTemplate

This is a starting template for a TypeScript web app that has the following tech stack:

  • Node.js
  • MySQL/MariaDB
  • Fastify
  • Prisma
  • Kysely
  • EJS
  • Tailwind

I created this to save myself the time of having to spend hours initializing and configuring a project every time I have an idea since this is already a pretty good starting point.

Setup

Setting up the application will consist of the following:

  1. Install MySQL/MariaDB server
  2. Create a new database for the application
  3. Create a new user with full access to the database
  4. Configure environment file with database connection information and other optional changes
  5. Installing node packages
  6. Running application

Database Setup

Docker

You have two options for setting up your database: configuring the Docker compose file or installing and configuring a server manually. If you choose to use Docker, all you have to do is configure the following values in the compose.yaml file:

  • MYSQL_ROOT_PASSWORD
  • MYSQL_DATABASE
  • MYSQL_USER
  • MYSQL_PASSWORD

You may also configure the port if desired. Whatever values you enter for the above compose.yaml file must also be copied to your .env file. See Configuring Environment File for more info.

After configuring the Docker compose file, all you have to do is run docker compose up -d.

Manual Install

This project was created using MariaDB and uses @prisma/adapter-mariadb. While MariaDB is compliant with MySQL and will probably have no issues working with MySQL, it is highly advised you use MariaDB for your database.

Once your database server is installed, you can run the following commands:

-- Create the database
CREATE DATABASE `foobar`
    CHARACTER SET utf8mb4
    COLLATE utf8mb4_unicode_ci;
 
-- Create the user (pls do not use the default password)
CREATE USER 'foo'@'%' IDENTIFIED BY '<PASSWORD>';
-- if you prefer a more locked down account that can only connect locally:
--CREATE USER 'foo'@'192.168.%' IDENTIFIED BY '<PASSWORD>';
 
-- Grant all privileges on the recipes database
GRANT ALL PRIVILEGES ON `foobar`.* TO 'foo'@'%';
 
-- Apply the privilege changes
FLUSH PRIVILEGES;

The names of the database and account are not important, nor is the host value for the account. Feel free to configure the database name, user name, and host. If you decide to do so, please remember to use the updated values later in the config.

Configuring Environment File

Once you've confirmed your database is fully configured and you can connect using the newly created account, you will need to populate the .env config file. You may rename the .env.example file to .env to have all required values pre-populated in the config.

The only required values to be updated are the keys prefixed with DB_, as these values are used to build the database connection string, and all the values under the # Security settings comment. For the SESSION_SECRET value, it is advised you generate a cryptographically random string of at least 32 characters.

# Application settings
APP_PORT=8080
# Environments - dev, prod
APP_ENVIRONMENT=prod

# Database settings
DB_HOST=<server IP>
DB_PORT=3306
DB_NAME=foobar
DB_USER=foo
DB_PASS=<PASSWORD>

# Security settings
SESSION_SECRET=a2VwdG9mZmljaWFsYXJyYW5nZW1lbnRpbmRlcGVuZGVudGxha2VjbGVhcmx5b2xkZXJibG9vZHRpcHNwZWVjaA==

Running Application

Once the .env file has been configured, you may now run the application. This application was developed with Node.js v25.9.0 and npm v11.12.1. Please see Node.js's download page for installation.

If/when you have Node.js installed, open a shell in the root of this project and run the following commands:

# Install Node.js packages
npm i

# Deploy database using provided connection information
npm run db:deploy

# Seed database with required data
npm run db:seed

# Run application
npm start

If successful, you will see the IP of the server in the console output.

S
Description
No description provided
Readme
254 KiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 60.1%
EJS 21.2%
CSS 15.4%
JavaScript 3.3%