Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Feb 1, 2024
2 parents 942799b + 05b9ae3 commit 915bdce
Show file tree
Hide file tree
Showing 19 changed files with 1,018 additions and 8 deletions.
68 changes: 64 additions & 4 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default {
'/wish/': wishGuide(),
'/create-sails/': createSailsGuide(),
'/inertia-sails/': inertiaSailsGuide(),
'/mail/': mailGuide()
'/mail/': mailGuide(),
'/boring-stack/': boringStackGuide()
},
sitemap: {
hostname: 'https://docs.sailscasts.com'
Expand All @@ -31,9 +32,7 @@ export default {
[
'script',
{
src: 'https://cdn.usefathom.com/script.js',
'data-site': 'OTDOQLCI',
'data-spa': 'auto',
src: 'https://tinylytics.app/embed/vL3m1tsfEzLruHrKLMHB.js',
defer: ''
}
]
Expand Down Expand Up @@ -264,3 +263,64 @@ function mailGuide() {
}
]
}

function boringStackGuide() {
return [
{
text: 'Introduction',
collapsed: false,
items: [
{ text: 'Why the name', link: 'boring-stack/why-the-name' },
{ text: 'Who is it for', link: 'boring-stack/who-is-it-for' },
{
text: "What's in the stack",
link: 'boring-stack/whats-in-the-stack'
},
{ text: 'Getting started', link: 'boring-stack/getting-started' }
]
},
{
text: 'The Basics',
collapsed: false,
items: [
{ text: 'Routing', link: 'boring-stack/routing' },
{ text: 'Navigation', link: 'boring-stack/navigation' },
{ text: 'Redirects', link: 'boring-stack/redirects' },
{ text: 'Error handling', link: 'boring-stack/error-handling' },
{ text: 'Sharing data', link: 'boring-stack/sharing-data' }
]
},

{
text: 'Guides',
collapsed: false,
items: [
{ text: 'Authentication', link: 'boring-stack/authentication' },
{ text: 'Authorization', link: 'boring-stack/authorization' },
{ text: 'Database', link: 'boring-stack/database' },
{ text: 'Email', link: 'boring-stack/email' },
{ text: 'Session', link: 'boring-stack/session' }
]
},
{
text: 'Deploy',
collapsed: false,
items: [
{
text: 'Render',
link: 'boring-stack/render'
}
]
},
{
text: 'Configuration',
collapsed: true,
items: [
{
text: 'Type checking JS files',
link: 'boring-stack/type-checking-js-files'
}
]
}
]
}
33 changes: 33 additions & 0 deletions docs/boring-stack/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Authentication
titleTemplate: The Boring JavaScript Stack 🥱
description: Authentication in The Boring JavaScript Stack
prev:
text: Sharing data
link: '/boring-stack/sharing-data'
next:
text: Authorization
link: '/boring-stack/authorization'
editLink: true
---

# {{ $frontmatter.title }} {#authentication}

Authentication is the process of verifying the identity of a user, typically through credentials like a username and password. For example, logging into a GitHub account requires authentication.

The Boring JavaScript Stack manages its own authentication.

By default, the Boring JavaScript Stack offers you two mechanisms for authentication:

1. Email and Password authentication
2. Provider authentication

## Email and password authentication

When a user wishes to sign up for an account, they are asked for their email address. The Boring Stack will send them an email with a link to verify their email. The user can click the link to verify their email address.

The password is stored using the bcrypt algorithm and handled by the password helper from [Sails organics](https://github.com/sailshq/sails-hook-organics).

## Provider authentication

Using [Sails Wish](/wish), The Boring Stack supports third-party authentication allowing you to easily add SSO(Single Sign On) to your application. Out of the box The Boring Stack supports [OAuth with Google](/wish/google). You can easily setup [OAuth with GitHub](/wish/github) as well.
47 changes: 47 additions & 0 deletions docs/boring-stack/authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Authorization
titleTemplate: The Boring JavaScript Stack 🥱
description: Authorization in The Boring JavaScript Stack
prev:
text: Authentication
link: '/boring-stack/authentication'
next:
text: Database
link: '/boring-stack/database'
editLink: true
---

# Authorization

Authorization is the process of granting or denying access to specific resources or actions based on a user's authenticated identity.

### Example Use Cases

- **Admin access control:** Authorizing certain users to access and manage administrative functionalities.
- **Content permissions:** Granting or denying users access to specific content or features based on their roles.
- **Secure transactions:** Allowing authorized users to perform secure transactions or financial operations.

Authorization within The Boring JavaScript Stack is orchestrated server-side through [Sails Policies](https://sailsjs.com/documentation/concepts/policies). These policies act as a shield, safeguarding your actions against unauthorized access.

A common scenario involves permitting a user to access your dashboard exclusively when authenticated. To implement this, you can establish a `api/policies/is-authenticated.js` policy and then configure the actions you wish the policy to safeguard in `config/policies.js`:

::: code-group

```js [api/policies/is-authenticated.js]
module.exports = async function (req, res, proceed) {
if (req.session.userId) return proceed()
return res.redirect('/login')
}
```

```js [config/policies.js]
module.exports.policies = {
'dashboard/*': 'is-authenticated'
}
```

:::

::: info
Learn more about using [policies](https://sailsjs.com/documentation/concepts/policies) for authorization on the Sails docs.
:::
97 changes: 97 additions & 0 deletions docs/boring-stack/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: Database
titleTemplate: The Boring JavaScript Stack 🥱
description: Database in The Boring JavaScript Stack
prev:
text: Authorization
link: '/boring-stack/authorization'
next:
text: Email
link: '/boring-stack/email'
editLink: true
---

# Database

A database is a structured collection of data organized for efficient retrieval and management. In web development, databases store and manage information essential for applications, such as user data, content, and settings.

### Example use cases

- **User data storage:** Storing and retrieving user profiles, preferences, and account information.
- **Content management:** Managing articles, posts, or any content within an application.
- **Configuration settings:** Storing and managing application settings and configurations.

## Sails Disk

During development, The Boring JavaScript Stack utilizes the [Sails Disk](https://sailsjs.com/documentation/concepts/extending-sails/adapters/available-adapters#sails-disk) adapter for Waterline, allowing you to kickstart your app without worrying about setting up a database.

::: info
Learn more about [Sails Disk](https://sailsjs.com/documentation/concepts/extending-sails/adapters/available-adapters#?sailsdisk) on the Sails docs.
:::

## Setting up a database

To set up a database, you can choose the adapter for your chosen database and follow the setup steps.

## PostgreSQL

::: code-group

```sh [terminal]
npm i sails-postgresql --save
```

```js [config/datastores.js]
module.exports.datastores = {
default: {
adapter: 'sails-postgresql', // [!code focus]
url: 'postgresql://user:password@host:port/database' // [!code focus]
}
}
```

:::

## MySQL

::: code-group

```sh [terminal]
npm i sails-mysql --save
```

```js [config/datastores.js]
module.exports.datastores = {
default: {
adapter: 'sails-mysql', // [!code focus]
url: 'mysql://user:password@host:port/database' // [!code focus]
}
}
```

:::

## MongoDB

::: code-group

```sh [terminal]
npm i sails-mongo --save
```

```js [config/datastores.js]
module.exports.datastores = {
default: {
adapter: 'sails-mongo', // [!code focus]
url: 'mongodb://user:password@host:port/database' // [!code focus]
}
}
```

:::

## SQLite <Badge type="warning" text="coming soon" />

::: info
The SQLite adapter is under development. You can keep an eye on the [repo](https://github.com/sailscastshq/sails-sqlite).
:::
45 changes: 45 additions & 0 deletions docs/boring-stack/email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Email
titleTemplate: The Boring JavaScript Stack 🥱
description: Sending emails in The Boring JavaScript Stack
prev:
text: Database
link: '/boring-stack/database'
next:
text: Session
link: '/boring-stack/session'
editLink: true
---

# Email

Sending transactional emails plays a crucial role in keeping users informed about specific actions or events. It involves delivering personalized and time-sensitive messages triggered by user interactions.

### Example use cases

- **User Registration Confirmation:** Sending an email to verify and confirm a user's registration.
- **Password Reset Requests:** Notifying users and providing a secure link to reset their passwords.
- **Order Confirmations:** Informing users about successful purchases with order details.

Sending emails in The Boring JavaScript is powered by the [Sails Mail](/mail) hook.

::: info
Learn all about [Sails Mail](/mail) in the Mail docs.
:::

## Sending emails

To send emails in The Boring JavaScript Stack, use the `sails.helpers.mail.send()` helper:

```js
// controllers/user/signup.js
await sails.helpers.mail.send.with({
subject: 'Verify your email',
template: 'email-verify-account',
to: unverifiedUser.email,
templateData: {
token: unverifiedUser.emailProofToken,
fullName: unverifiedUser.fullName
}
})
```
16 changes: 16 additions & 0 deletions docs/boring-stack/error-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Error handling
titleTemplate: The Boring JavaScript Stack 🥱
description: Error handling in The Boring JavaScript Stack
prev:
text: Redirects
link: '/boring-stack/redirects'
next:
text: Sharing data
link: '/boring-stack/sharing-data'
editLink: true
---

# Error handling

Coming soon :soon:
Loading

0 comments on commit 915bdce

Please sign in to comment.