Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions db/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const knex = require('knex');
const knexfile= require('../knexfile');
const client = knex(knexfile.development);


module.exports = client;
17 changes: 17 additions & 0 deletions db/migrations/20220301192527_clucks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

exports.up = function(knex) {

return knex.schema.createTable('clucks',table=>{
table.increments('id');
table.string('username');
table.string('image_url');
table.string('content',1000); //varchar 1000
table.timestamp('created_at').defaultTo(knex.fn.now());
table.timestamp('updated_at').defaultTo(knex.fn.now());
})
};

exports.down = function(knex) {

return knex.schema.dropTable('clucks')
};
12 changes: 12 additions & 0 deletions db/migrations/20220301230930_trending.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

exports.up = function(knex) {

return knex.schema.createTable('trending',table=>{
table.string('trend');
table.integer('count');
})
};

exports.down = function(knex) {
return knex.schema.dropTable('trending')
};
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const express = require('express');
const app = express();
const path = require('path');
const cookieParser = require('cookie-parser');
const methodOverride=require('method-override')
const logger = require('morgan');

//for static assests
app.use(express.static(path.join(__dirname, 'public')));
app.set('view engine', 'ejs');
app.use(express.urlencoded({ extended: true }));


app.use(cookieParser());
app.use(logger('dev'));


const userRouter = require('./routes/user')
app.use('/user',userRouter);

const cluckRouter = require('./routes/cluck')
app.use('/',cluckRouter);

const DOMAIN = 'localhost';
const PORT = 3000;
app.listen(PORT, DOMAIN, () => {
console.log(`Server listening on ${DOMAIN}:${PORT}`);
});
24 changes: 24 additions & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Update with your config settings.

/**
* @type { Object.<string, import("knex").Knex.Config> }
*/
module.exports = {

development: {
client: 'postgresql',
connection: {
database: 'cluckr',
username: 'abe',
password: 'BmP$S5%M'
},

migrations: {
tableName: "migrations",
directory: 'db/migrations'
},
seeds: {
directory: "db/seeds"
}
}
};
Loading