Published on

Getting Started with Intent

Authors

In this blog, you will learn the core fundamentals of Intent. We will setup a new project, understand the directory structure and getting it running.

Language

Intent uses Typescript as it's primary language.

Prerequisites

Make sure that Node.js (version >= 18) is installed on your operating system.

Setup

Setting up a new Intent project is quite easy with npm installed. You can run the following command in your terminal to get started.

It will ask you a few questions, you can choose Yes or No as per your requirement.

$ npx new-intent-app@latest

? What's your *Intent* to name this project? new-sample-app
? Are you planning to use AWS in your application? Yes
? Would you like to use Redis in your application? Yes
✔ Cloning repository
✔ Installing dependencies
✔ Setting up .env
✔ Reset git history

Once this command has ran, move to the directory new-sample-app and open it inside your fav code editor.

You will see a directory structure similar to the one mentioned below.

// Add Interatice Code Editor

You can read more about the directory structure here.

Configuring the Project

NOTE

Intent comes with default configuration with aim to help developers quickly setup the project and start building. You are free to make the changes as per your requirement.

Now when you open the .env inside the project, you will see set of following variables.

DEFAULT_DB=sqlite
DEFAULT_CACHE=memory
DEFAULT_QUEUE=sync
DEFAULT_STORAGE=local
DEFAULT_MAILER=logger

Let's understand these variables one by one.

DEFAULT_DB=sqlite

Whenever you launch a new project with Intent, it comes with SQLite configured as it's database. This helps you quickly get started.

If you wish to change the database configuration, click here.

DEFAULT_CACHE=memory

memory cache is the local cache, so you can start using Cache in your database without breaking a sweat.

If you wish to configure a different cache for your project, read more.

DEFAULT_QUEUE=sync

sync drivers are just a blank drivers which enable you to use queues in your application quickly. Read more about queues.

DEFAULT_STORAGE=local

Intent comes enabled with local storage by default with the files stored inside storage/uploads directory. Read more about storages.

DEFAULT_MAILER=logger

logger is the default driver of our Mailer, you can change this as per your requirement, to do so visit.

Running it locally

To run the project locally in watch mode, you can simply run the following command in your terminal.

$ npm run start:dev

Visit http://localhost:5001, and you should be greeted with a message.

Since, Intent comes with support for console commands as well, it will only be fair to have a look at that as well.

Headover to your terminal, and run the following command.

$ node intent greet

Horace Slughorn once said -
"It is impossible to manufacture or imitate love"

Voila 🎉 we are done with the project setup.

Formatting & Linting

Intent comes configured with eslint and prettier which you can use to lint and format your code respectively.

To do, you can make use of the following command.

$ npm run lint
$ npm run format

Running in Production

Just like any typescript project, you will need to first build the Intent app, and then start the server. To do so, you can make use of the following commands

$ npm run build
$ npm run start

Support

Though I am currently using Intent in multiple products, it's still the first release, so honestly there will be a few hidden bugs. If you run into any similar issues, you can either raise an issue here, or drop me an email at hi@tryintent.com for any support.

Licence

Intent is licensed under MIT © HanaLabs