Skip to content

Commit 0c5a9e8

Browse files
first commit
0 parents  commit 0c5a9e8

File tree

9,914 files changed

+408315
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

9,914 files changed

+408315
-0
lines changed

Diff for: .env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
WEBFLOW_CLIENT_ID=0b4b7e5900a9a010660c88b49124b2001b0fcf7154d2310c10f12119ca7ea529
2+
WEBFLOW_CLIENT_SECRET=08f0ecbbb588b32ef1b3f7ddc8fcadb5ab573c9658e1be7da6b91f00ff0673f5
3+
APP_TOKEN=8afbbceccd76e68bffd4a4ebce50c5cec9b3184983317983285137fab6db8db3

Diff for: README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- Create a CLI to run it
2+
- Create multiple examples
3+
- Guide Walkthrough
4+
- Airtable Sync
5+
- Notion Sync
6+
7+
8+
## Guide
9+
### Managing Collections
10+
- Retrieve All Collections: Fetch a list of all collections for a site.
11+
- Create a Collection: How to establish a new collection on your site.
12+
- Define Collection Schema: Create the fields in a collection.
13+
- Reference Fields
14+
### Managing Items
15+
- Retrieve Items: Fetch items from a collection, with options for sorting and filtering.
16+
- Add Items: Adding single or multiple items to a collection.
17+
- Item States: Manage the state of items (draft, published, etc.).
18+
- Update Items: How to modify existing items.

Diff for: backend/server.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { WebflowClient } from "webflow-api";
2+
import path from "path";
3+
import dotenv from "dotenv";
4+
import { fileURLToPath } from "url";
5+
import express from "express";
6+
import cors from "cors";
7+
import axios from "axios";
8+
9+
// Convert URL to local file path
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
13+
dotenv.config({ path: path.resolve(__dirname, "../.env") });
14+
15+
const app = express();
16+
const PORT = process.env.PORT || 8000;
17+
18+
// CORS options
19+
const corsOptions = {
20+
origin: "http://localhost:3000", // Allow only this origin to access the resources
21+
optionsSuccessStatus: 200, // For legacy browser support
22+
};
23+
24+
app.use(cors(corsOptions));
25+
app.use(express.json());
26+
27+
// Setup the Webflow Client
28+
const accessToken = process.env.APP_TOKEN;
29+
console.log(accessToken);
30+
const webflow = new WebflowClient({ accessToken });
31+
32+
// Endpoint to get all sites
33+
app.get("/api/sites", async (req, res) => {
34+
try {
35+
const data = await webflow.sites.list(); // Fetch sites from Webflow
36+
res.json(data.sites);
37+
} catch (error) {
38+
console.error("Error fetching sites:", error);
39+
res.status(500).send("Failed to fetch sites");
40+
}
41+
});
42+
43+
// Endpoint to create a new collection with fields
44+
app.post("/api/collections/:siteId", async (req, res) => {
45+
46+
// Formula to create fields in a collection
47+
async function createFields(collectionId, fields) {
48+
49+
for (const field of fields) {
50+
try {
51+
52+
// Create new field
53+
const response = await webflow.collections.fields.create(
54+
collectionId,
55+
field
56+
);
57+
58+
console.log("Field created:", response);
59+
} catch (error) {
60+
console.error("Error creating field:", field.name, error);
61+
}
62+
}
63+
}
64+
65+
try {
66+
const siteId = req.params.siteId;
67+
const collectionDetails = {
68+
displayName: req.body.collection.name,
69+
singularName: req.body.collection.singularName,
70+
slug: req.body.collection.slug,
71+
};
72+
const fields = req.body.collection.fields;
73+
console.log(siteId)
74+
const collection = await webflow.collections.create(siteId, collectionDetails);
75+
console.log(`Created Collection: ${collection.id} successfully`)
76+
await createFields(collection.id, fields);
77+
console.log("All fields created successfully.");
78+
} catch (error) {
79+
console.error("Failed to create collection or fields:", error);
80+
}
81+
});
82+
83+
// Endpoint to get collections for a specific site
84+
app.get("/api/collections/:siteId", async (req, res) => {
85+
try {
86+
const data = await webflow.collections.list(req.params.siteId);
87+
res.json(data.collections);
88+
} catch (error) {
89+
console.error("Error fetching collections:", error);
90+
res.status(500).send("Failed to fetch collections");
91+
}
92+
});
93+
94+
// Endpoint to get collection details
95+
app.get("/api/collections/:collectionId", async (req, res) => {
96+
97+
try{
98+
const data = await webflow.collections.get(req.params.collectionId)
99+
res.json(data)
100+
101+
} catch (error){
102+
console.error("Error fetching collection details:", error)
103+
res.status(500).send("Failed to fetch collection");
104+
105+
}
106+
107+
108+
})
109+
110+
111+
112+
app.listen(PORT, () => {
113+
console.log(`Server running on http://localhost:${PORT}`);
114+
});

Diff for: backend/utils/axiosInstance.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import axios from 'axios';
2+
3+
const axiosInstance = axios.create({
4+
baseURL: 'http://localhost:8000/api/', // Set your base URL here
5+
headers: {
6+
'Content-Type': 'application/json'
7+
}
8+
// You can add other default settings here
9+
});
10+
11+
export default axiosInstance;

Diff for: frontend/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

Diff for: frontend/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13+
14+
The page will reload when you make changes.\
15+
You may also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35+
36+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39+
40+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `npm run build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

0 commit comments

Comments
 (0)