Skip to content

Commit

Permalink
updated README and env example
Browse files Browse the repository at this point in the history
  • Loading branch information
fredygerman committed Sep 27, 2023
1 parent 0504c59 commit 2226ce3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 46 deletions.
42 changes: 0 additions & 42 deletions .env.example

This file was deleted.

25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# next-js-directus-starter
# Next js Directus Starter

Next.js 13 starter for building apps with Directus CMS Radix UI and Tailwind CSS.

Expand All @@ -8,18 +8,41 @@ Next.js 13 starter for building apps with Directus CMS Radix UI and Tailwind CSS
git clone https://github.com/fredygerman/next-js-directus-starter.git
```

### Change directory

```bash
cd next-js-directus-starter
```

### Install Dependencies

```bash
pnpm install
```

### Start Directus CMS

Make sure your Directus CMS is running and you have created a project.

### Define Environment Variables

```bash
cp .env.example .env
```

Note : Make sure all the environment variables are defined in your .env file.

For the DIRECTUS_DEFAULT_ROLE_ID you can use the default role id from your directus project.
For DIRECTUS_USER_CREATOR_TOKEN you need to create a user and a static token in your directus project.

### Start the development server

```bash
pnpm run dev
```

### You can now view the app in your browser at http://localhost:3000 🚀

## Features

- Next.js 13 App Directory
Expand Down
4 changes: 2 additions & 2 deletions env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const env = createEnv({
// DIRECTUS_URL: z.string().min(1), // this is how all the validation should be but for now since none of these are required we can leave them as optional
DIRECTUS_URL: z.string(),
DIRECTUS_TOKEN_EXPIRATION_ADJUSTMENT: z.string(),
DIRECTUS_USER_CHEATER_TOKEN: z.string().optional(),
DIRECTUS_USER_CREATOR_TOKEN: z.string().optional(),
DIRECTUS_DEFAULT_ROLE_ID: z.string(),
DIRECTUS_PROJECT_NAME: z.string().optional(),
GITHUB_CLIENT_ID: z.string().optional(),
Expand All @@ -27,7 +27,7 @@ export const env = createEnv({
DIRECTUS_TOKEN_EXPIRATION_ADJUSTMENT:
process.env.DIRECTUS_TOKEN_EXPIRATION_ADJUSTMENT,
DIRECTUS_DEFAULT_ROLE_ID: process.env.DIRECTUS_DEFAULT_ROLE_ID,
DIRECTUS_USER_CHEATER_TOKEN: process.env.DIRECTUS_USER_CHEATER_TOKEN,
DIRECTUS_USER_CREATOR_TOKEN: process.env.DIRECTUS_USER_CREATOR_TOKEN,
DIRECTUS_PROJECT_NAME: process.env.DIRECTUS_PROJECT_NAME,
GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
Expand Down
15 changes: 15 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -----------------------------------------------------------------------------
# App
# -----------------------------------------------------------------------------
NEXT_PUBLIC_APP_URL=http://localhost:3000


# -----------------------------------------------------------------------------
# Directus (Directus CRM)
# -----------------------------------------------------------------------------
DIRECTUS_URL=http://localhost:8055
DIRECTUS_PROJECT_NAME=directus
DIRECTUS_USER_CREATOR_TOKEN=XXXXXXXXXX
DIRECTUS_TOKEN_EXPIRATION_ADJUSTMENT=86400
DIRECTUS_DEFAULT_ROLE_ID=XXXXX
DIRECTUS_PROJECT_NAME=directus
2 changes: 1 addition & 1 deletion lib/directusApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const sendDirectusApiRequest = async (

if (useAuthHeader) {
const token = isRegistering
? env.DIRECTUS_USER_CHEATER_TOKEN
? env.DIRECTUS_USER_CREATOR_TOKEN
: bodyData?.access_token // maybe we should just always keep the token in the local storage and use it from there

console.log("token used is : ", token)
Expand Down

0 comments on commit 2226ce3

Please sign in to comment.