diff --git a/README.md b/README.md index 65cce41..3ed8c57 100644 --- a/README.md +++ b/README.md @@ -26,20 +26,18 @@ Set up the Backend: **Create .env in backend folder in this format with already configurated database in MySQL:** ``` -DB_HOST=localhost -DB_USER=root -DB_PASSWORD= -DB_NAME=smetovi -DB_PORT=4000 NODE_ENV=development - -SMTP_HOST=your-smtp-host # e.g., smtp.gmail.com -SMTP_PORT=your-smtp-port # e.g., 587 for TLS or 465 for SSL -SMTP_USER=your-email@gmail.com # Your email address -SMTP_PASS=your-app-password # Your app password for the email account -SENDER_EMAIL=your-sender-email # Email address from which the emails will be sent -DEFAULT_RECEIVER_EMAIL=recipient@example.com # Default recipient email address -DEFAULT_RECEIVER_NAME=your-reveiver-name # Name of the default recipient +DEV_DATABASE_URL = postgresql://neondb_owner:nekYVhH8Tzo6@ep-holy-moon-a5i4sdfw-pooler.us-east-2.aws.neon.tech/smetovi-dev?sslmode=require +JWT_SECRET=mysueprsecret +JWT_REFRESH_SECRET=myrefreshsupersecret +PORT=4000 +SMTP_HOST=host +SMTP_PORT=465 +SMTP_USER=smtp_user +SMTP_PASS=password +DEFAULT_SENDER_EMAIL=default_sender +DEFAULT_RECEIVER_EMAIL=default_receiver +DEFAULT_RECEIVER_NAME=Smetovi ``` Make sure to replace the placeholders with your actual values. @@ -52,7 +50,7 @@ then ``` cd backend npm i -npm run start +npm run dev ``` Running the Application diff --git a/backend/models/image.js b/backend/models/image.js new file mode 100644 index 0000000..ab3b7bb --- /dev/null +++ b/backend/models/image.js @@ -0,0 +1,23 @@ +const { DataTypes } = require("sequelize"); +const { sequelize } = require("../config/db"); + +const Image = sequelize.define( + "Image", + { + location_id: { + type: DataTypes.INTEGER, + allowNull: false, + }, + image_url: { + type: DataTypes.STRING, + allowNull: false, + }, + is_primary: { + type: DataTypes.BOOLEAN, + defaultValue: false, + }, + }, + { timestamps: true } +); + +module.exports = Image; diff --git a/backend/models/index.js b/backend/models/index.js index 20096de..85ea476 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -3,6 +3,7 @@ const Location = require('./location'); const Category = require('./category'); const RefreshToken = require('./refreshToken'); const Contact = require('./contact'); +const Image = require('./image'); const initModels = async () => { await User.sync(); @@ -10,6 +11,7 @@ const initModels = async () => { await Location.sync(); await RefreshToken.sync(); await Contact.sync(); + await Image.sync(); }; -module.exports = { User, Location, Category, RefreshToken, Contact, initModels }; \ No newline at end of file +module.exports = { User, Location, Category, RefreshToken, Contact, Image, initModels }; \ No newline at end of file diff --git a/backend/models/location.js b/backend/models/location.js index 36dad98..ba622cb 100644 --- a/backend/models/location.js +++ b/backend/models/location.js @@ -2,6 +2,7 @@ const { DataTypes } = require("sequelize"); const { sequelize } = require("../config/db"); const Category = require("./category"); const User = require("./user"); +const Image = require("./image"); const Location = sequelize.define( "Location", @@ -18,5 +19,6 @@ const Location = sequelize.define( Location.belongsTo(Category); Location.belongsTo(User); +Location.hasMany(Image); module.exports = Location; diff --git a/backend/routes/authRoutes.js b/backend/routes/authRoutes.js index 851f208..c72da6b 100644 --- a/backend/routes/authRoutes.js +++ b/backend/routes/authRoutes.js @@ -1,5 +1,6 @@ const express = require('express'); const { register, login, refreshToken, users } = require('../controllers/authController'); +const authMiddleware = require('../middleware/authMiddleware'); const router = express.Router(); if (process.env.NODE_ENV !== 'production') { @@ -7,6 +8,6 @@ if (process.env.NODE_ENV !== 'production') { } router.post('/login', login); router.post('/refresh-token', refreshToken); -router.get('/users', users); +router.get('/users', authMiddleware, users); module.exports = router; \ No newline at end of file diff --git a/frontend/src/app/home/pages/contact/contact.component.ts b/frontend/src/app/home/pages/contact/contact.component.ts index 07c4256..dae53e2 100644 --- a/frontend/src/app/home/pages/contact/contact.component.ts +++ b/frontend/src/app/home/pages/contact/contact.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { Meta, Title } from '@angular/platform-browser'; import { ContactFormComponent } from 'src/app/home/components/contact/contact-form/contact-form.component'; @Component({ @@ -8,4 +9,12 @@ import { ContactFormComponent } from 'src/app/home/components/contact/contact-fo standalone: true, imports: [ContactFormComponent], }) -export class ContactComponent {} +export class ContactComponent { + constructor(private title: Title, private meta: Meta) { + this.title.setTitle('Kontakt'); + this.meta.addTags([ + { name: 'description', content: 'Sve informacije na jednom mjestu o izletištu Smetovi kod Zenice' }, + { name: 'keywords', content: 'Smetovi, Izletište, Zenica, Snijeg, Kontakt' } + ]); + } +} diff --git a/frontend/src/app/home/pages/home/home.component.ts b/frontend/src/app/home/pages/home/home.component.ts index 8038105..a6eb50b 100644 --- a/frontend/src/app/home/pages/home/home.component.ts +++ b/frontend/src/app/home/pages/home/home.component.ts @@ -17,7 +17,7 @@ export class HomeComponent implements OnInit { locations: Location[] = []; constructor(private locationService: LocationService, private title: Title, private meta: Meta) { - this.title.setTitle('Početna - Dobro došli'); + this.title.setTitle('Početna - dobro došli na informativni portal o izletištu Smetovi'); this.meta.addTags([ { name: 'description', content: 'Sve informacije na jednom mjestu o izletištu Smetovi kod Zenice' }, { name: 'keywords', content: 'Smetovi, Izletište, Zenica, Snijeg' } diff --git a/frontend/src/app/home/pages/location/location.component.ts b/frontend/src/app/home/pages/location/location.component.ts index 5a626f5..2311bd4 100644 --- a/frontend/src/app/home/pages/location/location.component.ts +++ b/frontend/src/app/home/pages/location/location.component.ts @@ -6,7 +6,7 @@ import { GoogleMapsModule, MapMarker, MapInfoWindow } from '@angular/google-maps import { InfoWindowContent } from 'src/app/shared/models/info-window.model'; import { Marker } from 'src/app/shared/models/marker.model'; import { LocationService } from 'src/app/shared/services/location.service'; - +import { Title, Meta } from '@angular/platform-browser'; @Component({ selector: 'app-location', @@ -57,7 +57,13 @@ export class LocationComponent implements OnInit { name: '', image: '' }; - constructor(private locationService: LocationService) {} + constructor(private locationService: LocationService, private title: Title, private meta: Meta) { + this.title.setTitle('Lokacije - sve lokacije na jednom mjestu'); + this.meta.addTags([ + { name: 'description', content: 'Pregledajte sve lokacije koje se nalaze na Smetovima' }, + { name: 'keywords', content: 'Smetovi, Izletište, Zenica, Snijeg, Lokacije, Objekti' } + ]); + } ngOnInit() { this.locationService.getLocations().subscribe({