Aurelia 1.x Q&A - Sandbox at https://codesandbox.io/s/aurelia-javascript-sandbox-jnl6q85zq5
import { singleton } from '@aurelia/kernel';
import { LoggingWinston } from '@google-cloud/logging-winston';
import { instanceCachingFactory, registry } from 'tsyringe';
import winston, { format, Logger, LoggerOptions, transports } from 'winston';
export const LoggerDefault = 'defaultLogger';
export const LoggerTypeOrm = 'typeormLogger';
export const LoggerSecurity = 'securityLogger';
export const LoggerSecurityChild = 'childSecurityLogger';
@registry([
{ token: LoggerDefault, useFactory: instanceCachingFactory(createDefaultLogger) },
{ token: LoggerTypeOrm, useFactory: instanceCachingFactory(createTypeOrmLogger) },
{ token: LoggerSecurity, useFactory: instanceCachingFactory(createSecurityLogger) },
])
export class LoggerProvider {}
export function createDefaultLogger(): Logger {
const config: LoggerOptions =
process.env['NODE_ENV'] === 'development' ? devConfig() : serverConfig();
return winston.loggers.add(LoggerDefault, config);
}
function createTypeOrmLogger(): Logger {
const config: LoggerOptions =
process.env['NODE_ENV'] === 'development' ? devConfig() : serverConfig();
return winston.loggers.add(LoggerTypeOrm, config);
}
function createSecurityLogger(): Logger {
const config: LoggerOptions =
process.env['NODE_ENV'] === 'development' ? devConfig() : googleConfig();
return winston.loggers.add(LoggerSecurity, config);
}
function devConfig(): LoggerOptions {
const console = new transports.Console({
level: process.env.LOG_LEVEL || 'info',
debugStdout: true,
format: format.combine(format.cli(), format.splat(), format.simple()),
});
return {
transports: [console],
exceptionHandlers: [console],
};
}
function googleConfig(): LoggerOptions {
return {
transports: [
new LoggingWinston({
projectId: process.env.GOOGLE_SERVICE_ACCOUNT_PROJECT_ID,
credentials: {
client_email: process.env.GOOGLE_SERVICE_ACCOUNT_CLIENT_EMAIL!,
private_key: process.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY!,
},
}),
],
};
}
function serverConfig(): LoggerOptions {
return {
transports: [
new transports.Console({
level: process.env.LOG_LEVEL || 'info',
debugStdout: true,
format: format.combine(format.splat(), format.simple()),
}),
],
};
}
If I have a custom element and use the DOM remove()
function on it, will the unbind()
and detached()
lifecycle hooks on its view-model be called? For example
const myCustomElement = document.querySelector('#myCustomElement');
myCustomElement.remove()
I'm trying to track down whether I'm doing this incorrectly or if I should not expect those lifecycle hooks to be called when an element is removed from the DOM in this way.
I can confirm that those lifecycle hooks get called when the element is in a route and I navigate away from the route.
@processContent(...)
decorator within which I'm trying to register a custom component (like this example in the docs https://aurelia.io/docs/templating/custom-elements#decorators-for-customizing-aurelia-custom-element-processing sandbox link https://codesandbox.io/s/p7wo71qrzj?from-embed )
resources.registerElement(
"icon-list-item",
instruction.type["viewFactory"].resources.getElement("icon-list-item")
);
ERROR [templating] TypeError: Cannot read property 'resources' of undefined
viewFactory
can be undefined in a @processContent(...)
handler?
[HttpGet("{id:int}")]
. Having something like that would take care of it or being able to define a regex for a route param would also take care of it.
Hello. I used the information in the manual for setting up a simple aurelia with webpack, without using aurelia-cli. When I run npx webpack to build the project, I get this error:
ERROR in multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry aurelia-boostrapper
Module not found: Error: Can't resolve 'aurelia-webpack-plugin/runtime/empty-entry' in '' @ multi-aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-load-entry aurelia-bootstrapper main[0]
1
I've tried installing aurelia-pal-browser and aurelia-pal-nodejs with no change. Any ideas?