Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: yarn install && yarn run compile
command: yarn run start


4 changes: 2 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"host": "localhost",
"port": 14444,
"public": "../public/",
"public": "./public/",
"paginate": {
"default": 10,
"max": 50
},
"nedb": "../data",
"nedb": "./data",
"authentication": {
"entity": "user",
"service": "users",
Expand Down
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,28 @@
},
"types": "lib/",
"dependencies": {
"@bervproject/feathers-advance-hook": "^1.1.1",
"@feathersjs/authentication": "^4.5.15",
"@feathersjs/authentication-jwt": "^2.0.10",
"@feathersjs/authentication-local": "^4.5.15",
"@feathersjs/authentication-oauth": "^4.5.15",
"@feathersjs/configuration": "^4.5.15",
"@bervproject/feathers-advance-hook": "^2.0.3",
"@feathersjs/authentication": "^5.0.34",
"@feathersjs/authentication-local": "^5.0.34",
"@feathersjs/authentication-oauth": "^5.0.34",
"@feathersjs/configuration": "^5.0.34",
"@feathersjs/errors": "^5.0.33",
"@feathersjs/express": "^4.5.15",
"@feathersjs/feathers": "^4.5.15",
"@feathersjs/socketio": "^4.5.18",
"@feathersjs/express": "^5.0.34",
"@feathersjs/feathers": "^5.0.34",
"@feathersjs/socketio": "^5.0.34",
"cls-hooked": "^4.2.2",
"compression": "^1.8.0",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"feathers-authentication-hooks": "^1.0.2",
"feathers-hooks-common": "^6.1.5",
"feathers-hooks-common": "^8.2.1",
"feathers-permissions": "^2.1.4",
"feathers-sequelize": "^6.4.0",
"feathers-sequelize": "^7.0.3",
"helmet": "^8.1.0",
"pg": "^8.16.0",
"sequelize": "^6.37.7",
"serve-favicon": "^2.5.0",
"uuid": "^8.3.2",
"uuid": "^11.1.0",
"winston": "^3.17.0"
},
"devDependencies": {
Expand All @@ -69,8 +68,8 @@
"@types/serve-favicon": "^2.5.7",
"@types/uuid": "^9.0.0",
"@types/validator": "^13.15.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^8.32.1",
"@typescript-eslint/parser": "^8.32.1",
"axios": "^1.9.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.5",
Expand Down
23 changes: 15 additions & 8 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import compress from 'compression';
import helmet from 'helmet';
import cors from 'cors';

import feathers from '@feathersjs/feathers';
import { feathers } from '@feathersjs/feathers';
import configuration from '@feathersjs/configuration';
import express from '@feathersjs/express';
import express, {
json,
urlencoded,
static as staticFiles,
rest,
notFound,
errorHandler,
} from '@feathersjs/express';
import socketio from '@feathersjs/socketio';

import { Application } from './declarations';
Expand All @@ -26,14 +33,14 @@ app.configure(configuration());
app.use(helmet());
app.use(cors());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(json());
app.use(urlencoded({ extended: true }));
app.use(favicon(path.join(app.get('public'), 'favicon.ico')));
// Host the public folder
app.use('/', express.static(app.get('public')));
app.use('/', staticFiles(app.get('public')));

// Set up Plugins and providers
app.configure(express.rest());
app.configure(rest());
app.configure(socketio());

app.configure(sequelize);
Expand All @@ -47,8 +54,8 @@ app.configure(services);
app.configure(channels);

// Configure a middleware for 404s and the error handler
app.use(express.notFound());
app.use(express.errorHandler({ logger }));
app.use(notFound());
app.use(errorHandler({ logger }));

app.hooks(appHooks);

Expand Down
11 changes: 5 additions & 6 deletions src/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { ServiceAddons, Params } from '@feathersjs/feathers';
import { Params } from '@feathersjs/feathers';
import {
AuthenticationService,
JWTStrategy,
AuthenticationResult,
} from '@feathersjs/authentication';
import { LocalStrategy } from '@feathersjs/authentication-local';
import { expressOauth, OAuthProfile } from '@feathersjs/authentication-oauth';
import { oauth, OAuthProfile } from '@feathersjs/authentication-oauth';
import { OAuthStrategy } from '@feathersjs/authentication-oauth';

import { Application } from './declarations';

declare module './declarations' {
interface ServiceTypes {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
authentication: AuthenticationService & ServiceAddons<any>;
authentication: AuthenticationService;
}
}

Expand Down Expand Up @@ -65,6 +64,6 @@ export default function (app: Application): void {
authentication.register('local', new LocalStrategy());
authentication.register('google', new GoogleStrategy());

app.use('/authentication', authentication);
app.configure(expressOauth());
app.use('authentication', authentication);
app.configure(oauth());
}
4 changes: 3 additions & 1 deletion src/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Application as ExpressFeathers } from '@feathersjs/express';
import { HookContext as FeathersHookContext } from '@feathersjs/feathers';

// A mapping of service names to types. Will be extended in service files.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ServiceTypes {}
// The application instance type that will be used everywhere else
export type Application = ExpressFeathers<ServiceTypes>;
export type HookContext = FeathersHookContext<Application>;
6 changes: 3 additions & 3 deletions src/hooks/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// about the logger.
import logger from '../logger';
import util from 'util';
import { HookContext, Hook } from '@feathersjs/feathers';
import { HookContext } from '../declarations';

// To see more detailed messages, uncomment the following line:
logger.level = 'debug';

export default function (): Hook {
export default () => {
return (context: HookContext) => {
// This debugs the service call and a stringified version of the hook context
// You can customize the message (and logger) to your needs
Expand All @@ -28,4 +28,4 @@ export default function (): Hook {
logger.error(context.error.stack);
}
};
}
};
17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import app from './app';

const port = app.get('port');
const server = app.listen(port);

process.on('unhandledRejection', (reason, p) =>
logger.error('Unhandled Rejection at: Promise ', p, reason),
);

server.on('listening', () =>
logger.info(
'Feathers application started on http://%s:%d',
app.get('host'),
port,
),
);
app

Check warning on line 11 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L11

Added line #L11 was not covered by tests
.listen(port)
.then(() =>
logger.info(

Check warning on line 14 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L14

Added line #L14 was not covered by tests
'Feathers application started on http://%s:%d',
app.get('host'),
port,
),
);
10 changes: 2 additions & 8 deletions src/services/blog/blog.class.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { Service, SequelizeServiceOptions } from 'feathers-sequelize';
import { Application } from '../../declarations';
import { SequelizeService } from 'feathers-sequelize';

export class Blog extends Service {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(options: Partial<SequelizeServiceOptions>, app: Application) {
super(options);
}
}
export class Blog extends SequelizeService {}
5 changes: 4 additions & 1 deletion src/services/blog/blog.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as feathersAuthentication from '@feathersjs/authentication';
import { userAuditHook } from '@bervproject/feathers-advance-hook';
const { authenticate } = feathersAuthentication.hooks;
import checkPermissions from 'feathers-permissions';
import { HookOptions } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Blog } from './blog.class';

export default {
before: {
Expand Down Expand Up @@ -59,4 +62,4 @@ export default {
patch: [],
remove: [],
},
};
} as HookOptions<Application, Blog>;
6 changes: 2 additions & 4 deletions src/services/blog/blog.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Initializes the `blog` service on path `/blog`
import { ServiceAddons } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Blog } from './blog.class';
import createModel from '../../models/blog.model';
Expand All @@ -8,8 +7,7 @@ import hooks from './blog.hooks';
// Add this service to the service type index
declare module '../../declarations' {
interface ServiceTypes {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
blog: Blog & ServiceAddons<any>;
blog: Blog;
}
}

Expand All @@ -20,7 +18,7 @@ export default function (app: Application): void {
};

// Initialize our service with any options it requires
app.use('/blog', new Blog(options, app));
app.use('blog', new Blog(options));

// Get our initialized service so that we can register hooks
const service = app.service('blog');
Expand Down
10 changes: 2 additions & 8 deletions src/services/education/education.class.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { Service, SequelizeServiceOptions } from 'feathers-sequelize';
import { Application } from '../../declarations';
import { SequelizeService } from 'feathers-sequelize';

export class Education extends Service {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(options: Partial<SequelizeServiceOptions>, app: Application) {
super(options);
}
}
export class Education extends SequelizeService {}
5 changes: 4 additions & 1 deletion src/services/education/education.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as feathersAuthentication from '@feathersjs/authentication';
import { userAuditHook } from '@bervproject/feathers-advance-hook';
const { authenticate } = feathersAuthentication.hooks;
import checkPermissions from 'feathers-permissions';
import { HookOptions } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Education } from './education.class';

export default {
before: {
Expand Down Expand Up @@ -59,4 +62,4 @@ export default {
patch: [],
remove: [],
},
};
} as HookOptions<Application, Education>;
6 changes: 2 additions & 4 deletions src/services/education/education.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Initializes the `education` service on path `/education`
import { ServiceAddons } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Education } from './education.class';
import createModel from '../../models/education.model';
import hooks from './education.hooks';

declare module '../../declarations' {
interface ServiceTypes {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
education: Education & ServiceAddons<any>;
education: Education;
}
}

Expand All @@ -19,7 +17,7 @@ export default function (app: Application): void {
};

// Initialize our service with any options it requires
app.use('/education', new Education(options, app));
app.use('education', new Education(options));

// Get our initialized service so that we can register hooks
const service = app.service('education');
Expand Down
10 changes: 2 additions & 8 deletions src/services/experience/experience.class.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { Service, SequelizeServiceOptions } from 'feathers-sequelize';
import { Application } from '../../declarations';
import { SequelizeService } from 'feathers-sequelize';

export class Experience extends Service {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(options: Partial<SequelizeServiceOptions>, app: Application) {
super(options);
}
}
export class Experience extends SequelizeService {}
5 changes: 4 additions & 1 deletion src/services/experience/experience.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as feathersAuthentication from '@feathersjs/authentication';
import { userAuditHook } from '@bervproject/feathers-advance-hook';
const { authenticate } = feathersAuthentication.hooks;
import checkPermissions from 'feathers-permissions';
import { HookOptions } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Experience } from './experience.class';

export default {
before: {
Expand Down Expand Up @@ -59,4 +62,4 @@ export default {
patch: [],
remove: [],
},
};
} as HookOptions<Application, Experience>;
6 changes: 2 additions & 4 deletions src/services/experience/experience.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Initializes the `experience` service on path `/experience`
import { ServiceAddons } from '@feathersjs/feathers';
import { Application } from '../../declarations';
import { Experience } from './experience.class';
import createModel from '../../models/experience.model';
import hooks from './experience.hooks';

declare module '../../declarations' {
interface ServiceTypes {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experience: Experience & ServiceAddons<any>;
experience: Experience;
}
}

Expand All @@ -19,7 +17,7 @@ export default function (app: Application): void {
};

// Initialize our service with any options it requires
app.use('/experience', new Experience(options, app));
app.use('experience', new Experience(options));

// Get our initialized service so that we can register hooks
const service = app.service('experience');
Expand Down
10 changes: 2 additions & 8 deletions src/services/portofolio/portofolio.class.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { Service, SequelizeServiceOptions } from 'feathers-sequelize';
import { Application } from '../../declarations';
import { SequelizeService } from 'feathers-sequelize';

export class Portofolio extends Service {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(options: Partial<SequelizeServiceOptions>, app: Application) {
super(options);
}
}
export class Portofolio extends SequelizeService {}
Loading