Skip to content

Instantly share code, notes, and snippets.

@Noerdsteil
Noerdsteil / index.html
Created July 29, 2022 14:44
Responsive Timeline
<section>
<div class="container py-5">
<div class="row">
<div class="col-md-12">
<div class="main-timeline">
<div class="timeline">
<div class="timeline-content">
<div class="circle"><span class="homebox">
<img src="https://picsum.photos/164" class="img">
</span></div>
@Noerdsteil
Noerdsteil / serviceDependencies.js
Created December 19, 2019 16:39
How services are loaded before and after
// Contructor based DI (intermediary solution we had before)
const UserService = require('../user/userService')
const userService = new UserService(crmService, lhNotifier, userPropertyService)
// Note: All of the required services had to be managed in each occurrence
// Consistency was not the only pain we had
// With DI container in place
const { container, types } = require('../dependencyContainer')
const userService = container.get(types.UserService)
@Noerdsteil
Noerdsteil / dependencyContainer.ts
Created December 13, 2019 20:46
Extended dependency Container
import UserPropertyRepo from './account/repos/userPropertyRepo'
import UserRepo from './account/repos/userRepo'
container.bind<IUserPropertyRepo>(DI_TYPES.UserPropertyRepo).to(UserPropertyRepo)
container.bind<IUserRepo>(DI_TYPES.UserRepo).to(UserRepo)
@Noerdsteil
Noerdsteil / userEntity.js
Last active December 19, 2019 16:44
Sequelize association in userEntity
User.associate = function ({ Company, UserRole, Role }) {
// association for or table not needed anymore
// models.User.hasMany(models.Order)
User.belongsTo(Company, { as: 'company' })
User.belongsToMany(Role, { as: 'roles')
}
import { IUserPropertyService, IUserService, IUserRoleService} from '../interfaces/services'
import UserService from './account/userService'
import UserPropertyService from './account/userPropertyService'
import UserRoleService from './account/userRoleService'
container.bind<IUserService>(DI_TYPES.UserService).to(UserService)
container.bind<IUserPropertyService>(DI_TYPES.UserPropertyService).to(UserPropertyService)
container.bind<IUserRoleService>(DI_TYPES.UserRoleService).to(UserRoleService)