forked from abraham-yusuf/web3-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
abraham-yusuf
committed
Jun 1, 2022
1 parent
c891f39
commit 1012bfa
Showing
8 changed files
with
2,017 additions
and
1,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
HOST=0.0.0.0 | ||
PORT=1337 | ||
CLOUDINARY_KEY= | ||
CLOUDINARY_NAME= | ||
CLOUDINARY_SECRET= | ||
DATABASE_URL= | ||
ADMIN_JWT_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# Web3ID API | ||
|
||
### Running locally | ||
|
||
Create a folder and `git clone` from this repository. | ||
|
||
Install the dependencies and start the dev server. | ||
|
||
```bash | ||
yarn install | ||
yarn develop | ||
``` | ||
|
||
The strapi server will run on [http://localhost:1337](http://localhost:1337) | ||
|
||
Go to the admin panel [(http://localhost:1337/admin)](http://localhost:1337), create an account and start adding sample content. | ||
|
||
### Deployment | ||
|
||
First, you'll need a [Cloudinary](https://cloudinary.com) and a [Heroku](https://www.heroku.com/) account. | ||
|
||
1. From your copy of the repo click the "Deploy to Heroku" button | ||
|
||
<a href="https://www.heroku.com/deploy/?template=https://github.com/edgarlr/magazine-api"> | ||
<img src="https://assets.strapi.io/uploads/Deploy_button_heroku_b1043fc67d.png" /> | ||
</a> | ||
|
||
2. Fill the Cloudinary ENV variables. | ||
3. Deploy | ||
4. Once is deployed, go to the admin panel e.g. `https://yourherokudomain.com/admin` and create an account. | ||
5. Last, go to "Setting" > "Users & permissions plugins" > "Public" > "Permissions" and check `find` on Article, Category, Contributor and Pages. | ||
|
||
### Adding Content | ||
|
||
The recommended flow for adding new content is: | ||
|
||
- Add contributor | ||
- Add category | ||
- Add article or page | ||
|
||
### Preview Content | ||
|
||
Once you have your frontend deployed go to "Settings" > "Preview Content" | ||
|
||
Fill it with your info, the URL should look like this. | ||
`https://<yoursite.com>/api/:contentType-preview?secret=<your-secret>&id=:id` | ||
|
||
Now, go to any article or page and click on "Preview". | ||
|
||
*Note: Preview Content is Optional* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "Web3 API", | ||
"description": "API for NFT and Blog", | ||
"keywords": ["strapi", "heroku"], | ||
"repository": "https://github.com/abraham-yusuf/web3-api", | ||
"addons": ["heroku-postgresql:hobby-dev"], | ||
"image": "heroku/nodejs", | ||
"success_url": "/admin", | ||
"env": { | ||
"CLOUDINARY_NAME": { | ||
"description": "Cloud name of your cloudinary account", | ||
"generator": "" | ||
}, | ||
"CLOUDINARY_KEY": { | ||
"description": "API Key of your cloudinary account", | ||
"value": "" | ||
}, | ||
"CLOUDINARY_SECRET": { | ||
"description": "API Secret of your cloudinary account", | ||
"value": "" | ||
} | ||
}, | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/nodejs" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = ({ env }) => ({ | ||
defaultConnection: "default", | ||
connections: { | ||
default: { | ||
connector: "bookshelf", | ||
settings: { | ||
client: "postgres", | ||
host: env("DATABASE_HOST", "localhost"), | ||
port: env.int("DATABASE_PORT", 5432), | ||
database: env("DATABASE_NAME", "strapi"), | ||
username: env("DATABASE_USERNAME", "strapi"), | ||
password: env("DATABASE_PASSWORD", "strapi"), | ||
schema: "public", | ||
ssl: { rejectUnauthorized: false }, | ||
}, | ||
options: {}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = ({ env }) => ({ | ||
upload: { | ||
provider: "cloudinary", | ||
providerOptions: { | ||
cloud_name: env("CLOUDINARY_NAME"), | ||
api_key: env("CLOUDINARY_KEY"), | ||
api_secret: env("CLOUDINARY_SECRET"), | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
console.log("Start running postgres-env"); | ||
const fs = require("fs"); | ||
|
||
if (process.env.DATABASE_URL) { | ||
const databaseConfig = process.env.DATABASE_URL.split("//")[1]; | ||
const [username, passwordAndDb, hostAndPort] = databaseConfig.split(":"); | ||
const [password, host] = passwordAndDb.split("@"); | ||
const [port, databaseName] = hostAndPort.split("/"); | ||
const newLine = "\r\n"; | ||
let output = ""; | ||
|
||
output += `DATABASE_HOST=${host}${newLine}`; | ||
output += `DATABASE_PORT=${port}${newLine}`; | ||
output += `DATABASE_NAME=${databaseName}${newLine}`; | ||
output += `DATABASE_USERNAME=${username}${newLine}`; | ||
output += `DATABASE_PASSWORD=${password}${newLine}`; | ||
|
||
fs.writeFile(`./.env`, output, (err) => { | ||
if (err) { | ||
console.warn("create .env file error: ", err); | ||
} | ||
}); | ||
console.log(".env file is generated"); | ||
} | ||
|
||
console.log("Finish running postgres-env"); |
Oops, something went wrong.