To get the Tweedr API set up, you know the drill.
- Install dependencies
- Create database (
tweedr_dev) - Run seed & migration
- Start the server!
-
Run
createdb tweedr_devfrom the terminal. This will create the database that the tweedr express app is set up to use. -
Run
psql -d tweedr_dev -f migration_05192017.sqlfrom migration directory of thetweedrExpress app. -
Run
psql -d tweedr_dev -f seed.sqlfrom the seed directory of thetweedrExpress app. -
From
tweedrdirectory, which is the Express app, runyarn install. -
From the
tweedrdirectory, runcreate-react-app client. This will create a new directoryclientwith a react app in it. (It's convention to name the front-end portion of a full-stack buildclient.) -
In
tweedr/client/package.jsonadd"proxy": "http://localhost:3001/"to line 18. Make sure the line above it has a comma! -
Now, when you want to begin hacking, run
yarn startfrom thetweedrdirectory to start the Express app, and runyarn startfrom thetweedr/clientdirectory (in a new terminal tab) to start the React app. -
Don't forget to run the server and client at the same time.
Happy hacking!
Returns all tweeds in database.
{
"message": "ok",
"data": {
"tweeds": [
{
"id": "1",
"tweed": "Hello World!",
"tweed_time": "1494788500041"
},
{
"id": "2",
"tweed": "I love using Tweedr... so much better than twitter.",
"tweed_time": "1494788543350"
},
{
"id": "3",
"tweed": "React is the best!",
"tweed_time": "1494788564011"
},
{
"id": "4",
"tweed": "testing tweed upload",
"tweed_time": "1494792188509"
}
]
}
}Returns information about one specific tweed.
{
"message": "ok",
"data": {
"tweed": {
"id": "1",
"tweed": "Hello World!",
"tweed_time": "1494788500041"
}
}
}Adds a tweed to the database. Request body must include a tweed property.
A sample response looks like this:
{
"message": "ok",
"data": {
"tweed": {
"id": "5",
"tweed": "makin that tweed",
"tweed_time": "1494793073028"
}
}
}(The time is created in the controller.)
Edits a tweed in the database, based on that tweed's ID in the database. Request body must include a tweed property.
A sample response looks like this:
{
"message": "ok",
"data": {
"tweed": {
"id": "5",
"tweed": "this tweed has been edited",
"tweed_time": "1494793073028"
}
}
}Remove a tweed from the database, based on that tweed's ID in the database.
The response looks like this:
{
"message": "tweed deleted"
}