Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 730ee6e

Browse files
committed
Format code
1 parent 8fc821b commit 730ee6e

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"trailingComma": "es5",
33
"semi": false,
4-
"tabWidth": 2
4+
"tabWidth": 2,
5+
"single-quote": true
56
}

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "gatsby-source-strapi",
3-
"version": "0.0.3",
4-
"description":
5-
"Gatsby source plugin for building websites using Strapi as a data source",
3+
"version": "0.0.2",
4+
"description": "Gatsby source plugin for building websites using Strapi as a data source",
65
"author": {
76
"email": "[email protected]",
87
"name": "Strapi Solutions",
@@ -28,9 +27,15 @@
2827
"prepublish": "npm run build",
2928
"build": "babel src --out-dir .",
3029
"test": "echo \"Error: no test specified\" && exit 1",
30+
"format": "prettier --write 'src/**/*.js'",
3131
"watch": "babel -w src --out-dir ."
3232
},
33-
"keywords": ["gatsby", "gatsby-plugin", "gatsby-source-plugin", "strapi"],
33+
"keywords": [
34+
"gatsby",
35+
"gatsby-plugin",
36+
"gatsby-source-plugin",
37+
"strapi"
38+
],
3439
"dependencies": {
3540
"axios": "^0.17.1",
3641
"gatsby-node-helpers": "^0.1.3",

src/fetch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import axios from "axios"
2-
import { isObject, startsWith, forEach } from "lodash"
1+
import axios from 'axios'
2+
import { isObject, startsWith, forEach } from 'lodash'
33

44
module.exports = async ({ apiURL, contentType, jwtToken }) => {
5-
console.time("Fetch Strapi data")
5+
console.time('Fetch Strapi data')
66
console.log(`Starting to fetch data from Strapi (${contentType})`)
77

88
// Define API endpoint.
@@ -20,7 +20,7 @@ module.exports = async ({ apiURL, contentType, jwtToken }) => {
2020
const documents = await axios(apiEndpoint, fetchRequestConfig)
2121

2222
// Query all documents from client.
23-
console.timeEnd("Fetch Strapi data")
23+
console.timeEnd('Fetch Strapi data')
2424

2525
// Map and clean data.
2626
return documents.data.map(item => clean(item))

src/gatsby-node.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import axios from "axios"
2-
import fetchData from "./fetch"
3-
import { Node } from "./nodes"
4-
import { capitalize } from "lodash"
1+
import axios from 'axios'
2+
import fetchData from './fetch'
3+
import { Node } from './nodes'
4+
import { capitalize } from 'lodash'
55

66
exports.sourceNodes = async (
77
{ boundActionCreators },
8-
{ apiURL = "http://localhost:1337", contentTypes = [], loginData = {} }
8+
{ apiURL = 'http://localhost:1337', contentTypes = [], loginData = {} }
99
) => {
1010
const { createNode } = boundActionCreators
1111
let jwtToken = null
1212

1313
// Check if loginData is set.
1414
if (
15-
loginData.hasOwnProperty("identifier") &&
15+
loginData.hasOwnProperty('identifier') &&
1616
loginData.identifier.length !== 0 &&
17-
loginData.hasOwnProperty("password") &&
17+
loginData.hasOwnProperty('password') &&
1818
loginData.password.length !== 0
1919
) {
20-
console.time("Authenticate Strapi user")
21-
console.log("Authenticate Strapi user")
20+
console.time('Authenticate Strapi user')
21+
console.log('Authenticate Strapi user')
2222

2323
// Define API endpoint.
2424
const loginEndpoint = `${apiURL}/auth/local`
@@ -27,14 +27,14 @@ exports.sourceNodes = async (
2727
try {
2828
const loginResponse = await axios.post(loginEndpoint, loginData)
2929

30-
if (loginResponse.hasOwnProperty("data")) {
30+
if (loginResponse.hasOwnProperty('data')) {
3131
jwtToken = loginResponse.data.jwt
3232
}
3333
} catch (e) {
34-
console.error("Strapi authentication error: " + e)
34+
console.error('Strapi authentication error: ' + e)
3535
}
3636

37-
console.timeEnd("Authenticate Strapi user")
37+
console.timeEnd('Authenticate Strapi user')
3838
}
3939

4040
// Generate a list of promises based on the `contentTypes` option.

src/nodes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import createNodeHelpers from "gatsby-node-helpers"
1+
import createNodeHelpers from 'gatsby-node-helpers'
22

33
const { createNodeFactory } = createNodeHelpers({
4-
typePrefix: "Strapi",
4+
typePrefix: 'Strapi',
55
})
66

77
/**

0 commit comments

Comments
 (0)